IF EXISTS (SELECT *
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_NAME='pXXXXX'
AND ROUTINE_SCHEMA='dbo'
AND ROUTINE_TYPE='PROCEDURE'
)
DROP PROCEDURE dbo.pXXXXX
GO
CREATE PROC dbo.pXXXXX
@vintCurUserID INT,
@vintCurSysLID INT
AS
/*@@*_____________________________________________________________________
(c) 2013 XXXXX
Object: pXXXXX
Author: ...
Created: ...
Purpose:
...
...
...
Parameters:
@vintCurUserID: Current user context if available. NULL if unknown.
@vintCurSysLID: Language for translated text. NULL if unknown.
Recordsets:
Returns:
0 - Success
<>0 - Error occurred
Revision History:
Author dd-mmm-yyyy Purpose
_____________________________________________________________________*@@*/
/*______________________ CONSTANT DECLARATIONS _________________________*/
DECLARE
@cstrThisProc NVARCHAR(128),
@cintErrGeneral INT
SET @cstrThisProc = N'pXXXXX'
SET @cintErrGeneral = 50000 -- General error. Used when an
-- error has occurred and no other
-- specific error condition is
-- assigned.
/*______________________ VARIABLE DECLARATIONS _________________________*/
DECLARE
@intErrNo INT,
@strErrMsg NVARCHAR(400),
@intReturn INT
/*_______________________________ INIT _________________________________*/
-- Setting NOCOUNT ON prevents additional recordsets with the
-- "number of records affected" from being returned, which is not
-- handled the same by all providers, such as for OLEDB vs. ODBC.
SET NOCOUNT ON
/*________________________ VALIDATE PARAMETERS _________________________*/
/*_______________________________ MAIN _________________________________*/
-- Return value 0 indicates success
SET @intReturn = 0
lblExit:
RETURN @intReturn
/*___________________________ ERROR HANDLER ____________________________*/
lblError:
-- An error has occurred. On entering this section @intErrNo should
-- already hold the error number
-- By default, if there are any open transactions then roll them back
IF (@@TRANCOUNT > 0) BEGIN
ROLLBACK TRAN
END
-- If return value has not been explicitly set, then use the error
-- number as return value to signify failure
IF ((@intReturn IS NULL) OR (@intReturn = 0)) BEGIN
SET @intReturn = @intErrNo
END
GOTO lblExit
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_NAME='pXXXXX'
AND ROUTINE_SCHEMA='dbo'
AND ROUTINE_TYPE='PROCEDURE'
)
DROP PROCEDURE dbo.pXXXXX
GO
CREATE PROC dbo.pXXXXX
@vintCurUserID INT,
@vintCurSysLID INT
AS
/*@@*_____________________________________________________________________
(c) 2013 XXXXX
Object: pXXXXX
Author: ...
Created: ...
Purpose:
...
...
...
Parameters:
@vintCurUserID: Current user context if available. NULL if unknown.
@vintCurSysLID: Language for translated text. NULL if unknown.
Recordsets:
Returns:
0 - Success
<>0 - Error occurred
Revision History:
Author dd-mmm-yyyy Purpose
_____________________________________________________________________*@@*/
/*______________________ CONSTANT DECLARATIONS _________________________*/
DECLARE
@cstrThisProc NVARCHAR(128),
@cintErrGeneral INT
SET @cstrThisProc = N'pXXXXX'
SET @cintErrGeneral = 50000 -- General error. Used when an
-- error has occurred and no other
-- specific error condition is
-- assigned.
/*______________________ VARIABLE DECLARATIONS _________________________*/
DECLARE
@intErrNo INT,
@strErrMsg NVARCHAR(400),
@intReturn INT
/*_______________________________ INIT _________________________________*/
-- Setting NOCOUNT ON prevents additional recordsets with the
-- "number of records affected" from being returned, which is not
-- handled the same by all providers, such as for OLEDB vs. ODBC.
SET NOCOUNT ON
/*________________________ VALIDATE PARAMETERS _________________________*/
/*_______________________________ MAIN _________________________________*/
-- Return value 0 indicates success
SET @intReturn = 0
lblExit:
RETURN @intReturn
/*___________________________ ERROR HANDLER ____________________________*/
lblError:
-- An error has occurred. On entering this section @intErrNo should
-- already hold the error number
-- By default, if there are any open transactions then roll them back
IF (@@TRANCOUNT > 0) BEGIN
ROLLBACK TRAN
END
-- If return value has not been explicitly set, then use the error
-- number as return value to signify failure
IF ((@intReturn IS NULL) OR (@intReturn = 0)) BEGIN
SET @intReturn = @intErrNo
END
GOTO lblExit
No hay comentarios:
Publicar un comentario