How to run multiple execute statements in store procedure?

I have a stored procedure that I call using the store procedure smart service in the process model. I have 2 update statements in the SP but when I run it using appian it only runs the first one and doesn't throw any errors.

 

This is my store procedure code, note that all the names in lowercase are input paramaters

 

BEGIN

DECLARE startTime datetime;
DECLARE SQLStateCode varchar(5) DEFAULT '00000';
DECLARE ErrorNumber int;
DECLARE MessageText varchar(1000);

-- insert / update

set @sql = concat("UPDATE
  XCS_APP_CERTIFICATION
SET
  COMPLETED_HOURS = COMPLETED_HOURS + ", courseHours , ",
  LAST_MODIFIED_BY = '", lastModifiedBy, "',
  LAST_MODIFIED_ON = NOW()
WHERE
XCS_APP_CERTIFICATION.CREATED_BY in (" , addAttendeeUsername , ") AND VALID_START_DATE <= '", offeringEndDateTime, "'
  AND GRACE_PER_END_DATE >= '", offeringEndDateTime,"' ");


set @sql2 = concat("UPDATE
  XCS_APP_CERTIFICATION
SET
  COMPLETED_HOURS = COMPLETED_HOURS - ", courseHours, ",
  LAST_MODIFIED_BY = '", lastModifiedBy, "',
  LAST_MODIFIED_ON = NOW()
WHERE
  CREATED_BY IN (", removeAttendeeUsername, ")  AND VALID_START_DATE <= '", offeringEndDateTime, "'
  AND GRACE_PER_END_DATE >= '", offeringEndDateTime, "' ");
	
    
    IF addAttendeeUsername IS NOT NULL THEN
    	PREPARE stmt FROM @sql;
    	EXECUTE stmt;
    END IF;
    
    IF removeAttendeeUsername IS NOT NULL THEN
    	PREPARE stmt2 FROM @sql2;
    	EXECUTE stmt2;
    END IF;
   
    
set successFlag = 1;

-- committing transaction
COMMIT;

END

 

If I wanted to call this directly from SLQ I can run it like this which works fine. CALL XCS_SP_UPDATE_HOURS("'aapplicant'", "'aapplicant001'", NOW(), 2.5, 'stewie', NOW(), @out). The problem is with running it using the process model. I can't find any documentation on this smart service online. What are the limitations on it or any other gotchas I should be aware of?

  Discussion posts and replies are publicly visible

Parents
  • Hi Jose,
    Both the update statements are executed using a If condition block as mentioned in the code snippet above.

    IF removeAttendeeUsername IS NOT NULL THEN
    PREPARE stmt2 FROM @sql2;
    EXECUTE stmt2;
    END IF;

    Can you check if this value (removeAttendeeUsername) is passed to Stored Procedure which is required for the second update statment?

    Regards,
    Vadivelan
Reply
  • Hi Jose,
    Both the update statements are executed using a If condition block as mentioned in the code snippet above.

    IF removeAttendeeUsername IS NOT NULL THEN
    PREPARE stmt2 FROM @sql2;
    EXECUTE stmt2;
    END IF;

    Can you check if this value (removeAttendeeUsername) is passed to Stored Procedure which is required for the second update statment?

    Regards,
    Vadivelan
Children
No Data