USP_JOURNALCODE_CREATEENTRY
Creates a new table entry for the "Transaction Journal" code table.
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@DESCRIPTION | nvarchar(100) | IN | The table entry description. |
@ACTIVE | bit | IN | Indicates whether or not the table entry is active. |
@SEQUENCE | int | IN | The table entry sequence (when the code table sort order is user-defined). |
@CHANGEAGENTID | uniqueidentifier | IN | The ID of the change agent adding the code table entry. |
@ID | uniqueidentifier | INOUT | The ID of the newly added code table entry. |
Definition
Copy
/*
Generated by Blackbaud AppFx Platform
Date: 9/30/2015 1:01:22 AM
Assembly Version: Blackbaud.AppFx.Platform.SqlClr, Version=4.0.153.0, Culture=neutral, PublicKeyToken=null
Copyright Blackbaud
*/
CREATE procedure dbo.USP_JOURNALCODE_CREATEENTRY
(
@DESCRIPTION nvarchar(100)='',
@ACTIVE bit=1,
@SEQUENCE int = null,
@CHANGEAGENTID uniqueidentifier = null,
@ID uniqueidentifier = null output
)
as
SET NOCOUNT ON;
if (@DESCRIPTION IS NULL) or len(@DESCRIPTION)= 0
begin
raiserror('Description is required to create a JOURNALCODE table entry',16,1)
return -2
end
if @CHANGEAGENTID IS NULL
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
if @ID IS NULL SET @ID=newid();
if @SEQUENCE is null
select @SEQUENCE = coalesce(max(SEQUENCE) + 1, 1) from dbo.JOURNALCODE
insert into dbo.JOURNALCODE
(
ID,DESCRIPTION,ACTIVE,SEQUENCE,ADDEDBYID,CHANGEDBYID,DATEADDED,DATECHANGED
)
VALUES
(
@ID,@DESCRIPTION,@ACTIVE,@SEQUENCE,@CHANGEAGENTID,@CHANGEAGENTID,getDate(),getDate()
);
update dbo.JOURNALCODE
set SEQUENCE = SEQUENCE + 1,
CHANGEDBYID=@CHANGEAGENTID,
DATECHANGED=GETDATE()
where SEQUENCE >= @SEQUENCE and ID <> @ID
if @@error<>0 return 1
return 0