USP_DATAFORMTEMPLATE_EDIT_DEMOGRAPHIC

USP_DATAFORMTEMPLATE_EDIT_DEMOGRAPHIC

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter indicating the ID of the record being edited.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@ETHNICITYCODEID uniqueidentifier IN Ethnicity
@RELIGIONCODEID uniqueidentifier IN Religion
@TARGETCODEID uniqueidentifier IN Target
@INCOMECODEID uniqueidentifier IN Income
@BIRTHPLACE nvarchar(50) IN Birthplace

Definition

Copy


CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_DEMOGRAPHIC
(
    @ID uniqueidentifier,
    @CHANGEAGENTID uniqueidentifier = null,
    @ETHNICITYCODEID uniqueidentifier,
    @RELIGIONCODEID uniqueidentifier,
    @TARGETCODEID uniqueidentifier,
    @INCOMECODEID uniqueidentifier,
    @BIRTHPLACE nvarchar(50)
) as
    set nocount on;

    declare @CURRENTDATE datetime;

    if @CHANGEAGENTID is null
        exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;

    set @CURRENTDATE = getdate();

    declare @DEMOGRAPHICETHNICITIES xml;

    -- load new fields

    exec dbo.USP_DATAFORMTEMPLATE_EDITLOAD_DEMOGRAPHIC
        @ID = @ID,
        @DEMOGRAPHICETHNICITIES = @DEMOGRAPHICETHNICITIES output


    begin try

        -- call new save

        exec dbo.USP_DATAFORMTEMPLATE_EDIT_DEMOGRAPHIC_2
            @ID
            @CHANGEAGENTID
            @ETHNICITYCODEID
            @RELIGIONCODEID
            @TARGETCODEID
            @INCOMECODEID
            @BIRTHPLACE,
            @DEMOGRAPHICETHNICITIES

    end try
    begin catch
        exec dbo.USP_RAISE_ERROR;
        return 1;
    end catch

    return 0;