1

I'm developing an SSIS package that will pump data from a Data Source to an MDS data model\entity.

I have an execute SQL task which should validate the MDS Facility entity.

Here is the script:

DECLARE @ModelName nVarchar(50) = 'DEV ERP'
DECLARE @Model_id int
DECLARE @UserName nvarchar(50) = 'System'
DECLARE @User_ID int
DECLARE @Version_ID int
SET @User_ID =  (SELECT ID 
                 FROM mdm.tblUser u
                 WHERE u.UserName = @UserName)
SET @Model_ID = (SELECT Model_ID
                 FROM mdm.viw_SYSTEM_SCHEMA_VERSION
                 WHERE Model_Name = @ModelName)
SET @Version_ID = (SELECT MAX(ID)
                   FROM mdm.viw_SYSTEM_SCHEMA_VERSION
                   WHERE Model_ID = @Model_ID)
EXECUTE mdm.udpValidateModel @User_ID, @Model_ID, @Version_ID, 1

Here is the error I'm getting when trying to execute the task:

[Execute SQL Task] Error: Executing the query "DECLARE @ModelName nVarchar(50) = 'DEV ERP' DECLAR..." failed with the following error: "SYSERR515|Cannot insert the value NULL into column 'EnterUserID', table 'MDS.mdm.tblEvent'; column does not allow nulls. INSERT fails., @ErrorNumber = 515, @ErrorProcedure = "udpSystemEventSave", line 60". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

I was wondering how can I overcome this issue since I cannot declare the variable as a NOT NULL value. Before passing that variable how can I check the record is valid record or not?

0

1 Answer 1

0
IF @User_ID IS NULL
    BEGIN

        -- Handle it here.

    END
;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.