Pervasive logo

Prev SQL Engine Reference Next

DECLARE


Remarks

Use the DECLARE statement to define an SQL variable.

This statement is allowed only inside of a stored procedure or a trigger, since cursors and variables are allowed only inside of stored procedures and triggers.

The name of a variable must begin with a colon (:), both in the definition and use of the variable or parameter. A variable must be declared before it can be set to a value with SET VARIABLE.

Use a separate DECLARE statement for each variable (you cannot declare multiple variables with a single statement). Specify a value or values for data types that require a size, precision, or scale, such as CHAR, DECIMAL, NUMERIC, and VARCHAR.

Examples

The following examples show how to declare variables, including ones that require a value for size, precision, or scale.

DECLARE :SaleItem CHAR(15); 
DECLARE :CruiseLine CHAR(25) DEFAULT 'Open Seas Tours' 
DECLARE :UnitWeight DECIMAL(10,3); 
DECLARE :Titration NUMERIC(12,3); 
DECLARE :ReasonForReturn VARCHAR(200); 
DECLARE :Counter INTEGER = 0; 
DECLARE :CurrentCapacity INTEGER = 9; 

See Also

CREATE PROCEDURE

CREATE TRIGGER

SET VARIABLE


Prev
CREATE VIEW
Contents
Up
Check for Revisions
Next
DECLARE CURSOR