Receiving and Using a Response from the Save to SQL Server Action

Applies to Infiniti v8.1 or later
 

Often the response from a stored procedure call via the Save to SQL Server Action is required for further calls. Most commonly the response is some sort of identifier created by the stored procedure for use in an on screen message, email, SMS etc.

After a successful Save to SQL Server Action is performed a response is returned to Infiniti that can be used by pending actions. Specifically this response is the first column of the first row in the result set returned by the query, additional columns and rows are ignored (also known as the executeScalar response).

For example in the following stored procedure the ID of the new record will be returned to Infiniti.

CREATE PROCEDURE spAddPerson

      -- Add the parameters for the stored procedure here

      @firstName nvarchar(255),

      @surname nvarchar(255)    

AS

BEGIN

      -- SET NOCOUNT ON added to prevent extra result sets from

      -- interfering with SELECT statements.

      SET NOCOUNT ON;



    INSERT INTO Person (firstName,surname)

    VALUES (@firstName,@surname);

    SELECT @@IDENTITY AS 'Id';

END

GO

The value can then be used by a reference with the following syntax:

[ActionName.Response]

e.g. [Save to SQL Server Database.Response]

e.g. [AddPerson.Response]

In the example below the response will be displayed in a download page message. TIP this is a good method of testing your Save to SQL Server Actions.

 

Related Articles

Save to SQL Action

 

Keywords

first name firstname add person