상세 컨텐츠

본문 제목

[DATABASE - PROCEDURE] PROCEDURE 생성

IDEA/CKMC

by luckey 2014. 11. 4. 15:57

본문

1. SP_USER_MEMBER_CREATE

2. SP_MASTER_CATEGORY_CREATE

3. SP_USER_CONTENTS_CREATE

4. SP_MASTER_CONTENTS_HISTORY_CREATE

 

 

/**

author : 정우창

e-mail : ultra102@nate.com

created date : 2014-11-04

project name : CKMC

description : 회원가입정보(아이디)를 체크하고 없을경우 데이터를 등록합니다.

return value :

0 = 등록완료

9 = 가입된 정보(이메일주소)가 있어서 등록불가능

execute test : SP_USER_MEMBER_CREATE

 'ckmc.master@gmail.com', 'NjqStiCwrhJio8amponccaMCGm5XYN1qg1tVudfZCVE=', '0.0.0.0'

**/

 

CREATE PROC SP_USER_MEMBER_CREATE

(

@memID VARCHAR(50),

@memPW VARCHAR(44),

@memIP VARCHAR(15)

)

as

begin

SET NOCOUNT ON;

DECLARE @errorCode CHAR(1)

SET @errorCode = '0'

 

if not exists(select PK_memberNumber from TBL_MEMBER with(nolock) where memberID='ultra102@nate.com') --가입성공

INSERT INTO TBL_MEMBER(memberID, memberPW, memberRegistIP) values (@memID, @memPW, @memIP)

else -- 가입실패(이미 사용중인 메일주소가 있음)

SET @errorCode = '9'

end

 

/**

author : 정우창

e-mail : ultra102@nate.com

created date : 2014-11-04

project name : CKMC

description : 카테고리등록

return value : 없음

execute test : SP_MASTER_CATEGORY_CREATE '카테고리명'

**/

 

CREATE PROC SP_MASTER_CATEGORY_CREATE

(

@cateName NVARCHAR(10)

)

AS

BEGIN

SET NOCOUNT ON;

INSERT INTO TBL_CATEGORY(categoryName) VALUES(@cateName)

END

 

/**

author : 정우창

e-mail : ultra102@nate.com

created date : 2014-11-04

project name : CKMC

description : 컨텐츠등록

return value : 등록된 컨텐츠의 고유번호값

execute test : SP_USER_CONTENTS_CREATE '글제목4', '글내용4', '썸네일이미지주소', '1000000000'

**/

ALTER PROC SP_USER_CONTENTS_CREATE

(

@contsTitle NVARCHAR(100),

@contsText NVARCHAR(MAX),

@contsThumb VARCHAR(50),

@postMember NUMERIC(10)

)

AS

BEGIN

SET NOCOUNT ON;

INSERT INTO TBL_CONTENTS(contentsTitle, contentsText, contentsThumbnail, FK_PostMember_MEMBER) VALUES (@contsTitle, @contsText, @contsThumb, @postMember)

END

 

/**

author : 정우창

e-mail : ultra102@nate.com

created date : 2014-11-04

project name : CKMC

description : 컨텐츠등록

return value : 없음

execute test : SP_MASTER_CONTENTS_HISTORY_CREATE 1, 'I', '1000000000', '홍길동님이 새로운 글을 등록했습니다.'

**/

CREATE PROC SP_MASTER_CONTENTS_HISTORY_CREATE

(

@contsIdx BIGINT,

@contsType char(1),

@contsMember NUMERIC(10),

@contsText NVARCHAR(100)

)

AS

BEGIN

SET NOCOUNT ON;

INSERT INTO TBL_CONTENTS_HISTORY(FK_contentsIdx_CONTENTS, contentsHistoryType, contentsHistoryMember, contentsHistoryText) VALUES (@contsIdx, @contsType, @contsMember, @contsText)

END

관련글 더보기

댓글 영역