PROCEDURE
/**********************************************************************
0. 버전 : SQL Server
1. 스토어드명 :
2. 목적& 기능 :
3. 생성일자 :
4. 생성자 :
5. 실행예 :
6. 파라메타 :
7. 반환값 :
**********************************************************************/
CREATE PROCEDURE [dbo].[P_SELECT]
(
@P_EMP_NO VARCHAR(10)
)
WITH ENCRYPTION -- 암호화
AS
BEGIN
BEGIN TRY
DECLARE @iCursor_Cnt INT;
-- Error 발생
BEGIN
RAISERROR ('오류 메세지 입니다.\r\n Error.', 16, 1) WITH SETERROR;
RETURN;
END
END TRY
BEGIN CATCH
-- Cursor 사용시 해제
/*
IF (SELECT CURSOR_STATUS('global','CAL_CURSOR')) >= -1
BEGIN
IF (SELECT CURSOR_STATUS('global','CAL_CURSOR')) > -1
BEGIN
CLOSE DUTY_CURSOR
END
DEALLOCATE DUTY_CURSOR
END
*/
-- Cursor 사용시 해제
--SELECT @iCursor_Cnt = CURSOR_STATUS('global','BBA_REC1');
--IF @iCursor_Cnt = 1
--BEGIN
-- CLOSE BBA_REC1;
-- DEALLOCATE BBA_REC1;
--END;
DECLARE @ErrorMessage NVARCHAR(4000);
DECLARE @ErrorSeverity INT;
DECLARE @ErrorState INT;
DECLARE @ErrorProcedure NVARCHAR(4000);
SELECT @ErrorMessage = ERROR_MESSAGE()
, @ErrorSeverity = ERROR_SEVERITY()
, @ErrorState = ERROR_STATE()
, @ErrorProcedure = ERROR_PROCEDURE() + '(' + CAST(ERROR_LINE() AS VARCHAR) + ')'
RAISERROR (@ErrorMessage,
@ErrorSeverity, -- Severity.
@ErrorState, -- State.
@ErrorProcedure)
END CATCH;
END;