Connection-level variables are declared with the CREATE VARIABLE statement. Connection-level variables can be passed as parameters to procedures.
The syntax for the CREATE VARIABLE statement is as follows:
CREATE VARIABLE variable-name data-type
When a variable is created, it is initially set to NULL. The value of connection-level variables can be set in the same way as local variables, using the SET statement or using a SELECT statement with an INTO clause.
Connection-level variables exist until the connection is terminated, or until the variable is explicitly dropped using the DROP VARIABLE statement. The following statement drops the variable con_var:
DROP VARIABLE con_var; |
The following batch of SQL statements illustrates the use of connection-level variables.
CREATE VARIABLE con_var INT; SET con_var = 10; MESSAGE 'con_var = ', con_var TO CLIENT; |
Running this batch from Interactive SQL displays the message con_var = 10
in the Messages tab of the Interactive SQL Results pane.
SQL/2008 Vendor extension.
![]() |
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |