본문 바로가기
ICT

[SQL] Procedure for Creating a New Account in Canteen System

by NeoSailer 2024. 3. 4.

[Requirements]

- SQL a procedure creating a new account in canteen system

 

[OS] 

Windows Server 2021 R2

 

[Development Language]

SQL

 

[IDE]

SSMS(SQL Server Management Studio)

 

[Setting]

-

 

[Code]

USE [YTC_OPERATION]
GO
/****** Object:  StoredProcedure [dbo].[CREATE_USER]    Script Date: 2024-03-04 오후 4:27:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[CREATE_USER](@name nvarchar(20), @id nvarchar(10), @pw nvarchar(10), @qty int)
AS
BEGIN

INSERT USRS_temp (EMID, Name, Tele, PSWD, Stat, UDLQ)
VALUES ((select max(cast(emid as int))+1 from usrs_temp), @name, @id, @pw, 'W', @qty)

END

 

 

[Test]

exec CREATE_USER /*이름*/'하하하', /*ID*/'1004', /*비밀번호*/'1004', /*식대수*/1

select * from USRS_temp where Name ='하하하'

 

 

[Lesson Learned]

- Column type configuration should be done with full consideration otherwise data parsing query step is demanded and it would be a big pain

반응형

댓글