Icon SET

Assigns a value to a variable, parameter, or trigger NEWROW value.

Syntax
SET <TargetName> = <Expression> [,<TargetName> = <Expression>]

<TargetName> =

<VariableName>|<ParameterName>|NEWROW.<ColumnName>

Usage
Use this statement to assign a value to a variable, parameter, or trigger NEWROW value.

Examples
-- This function uses the SET
-- statement to assign the count of the
-- rows in the Customers table to the
-- result variable returned from the function

CREATE FUNCTION CountCustomers()
RETURNS INTEGER
BEGIN
   DECLARE Test SENSITIVE CURSOR FOR stmt;
   DECLARE Result INTEGER DEFAULT 0;

   PREPARE stmt FROM 'SELECT * FROM Customers';

   OPEN Test;

   FETCH FIRST FROM Test;

   WHILE NOT EOF(Test) DO
      SET Result = Result + 1;
      FETCH NEXT FROM Test;
   END WHILE;

   RETURN Result;
END

SQL 2003 Standard Deviations
This statement deviates from the SQL 2003 standard in the following ways:

DeviationDetails
None
Image