用动态SQL
Description
Use this format to execute a SQL statement that produces a result set in which the input parameters and result set columns are known at compile time.
Syntax
DECLARE Cursor | Procedure
DYNAMIC CURSOR | PROCEDURE
FOR DynamicStagingArea ;
PREPARE DynamicStagingArea FROM SQLStatement
{USING TransactionObject} ;
OPEN DYNAMIC Cursor
{USING ParameterList} ;
EXECUTE DYNAMIC Procedure
{USING ParameterList} ;
FETCH Cursor | Procedure
INTO HostVariableList ;
CLOSE Cursor | Procedure ;
Parameter
Description
Cursor or Procedure
The name of the cursor or procedure you want to use
DynamicStagingArea
The name of the DynamicStagingArea (usually SQLSA)If you need a DynamicStagingArea variable other than SQLSA, you must declare it and instantiate it with the CREATE statement before using it
SQLStatement
A string containing a valid SQL SELECT statement The string can be a string constant or a PowerBuilder variable preceded by a colon (such as :mysql). The string must be contained on one line and cannot contain expressions Enter a question mark (?) for each parameter in the statement. Value substitution is positional; reserved word substitution is not allowed
TransactionObject (optional)
The name of the transaction object that identifies the database
ParameterList (optional)
A comma-separated list of PowerScript variables. Note that PowerScript variables are preceded by a colon (
HostVariableList
The list of PowerScript variables into which the data values will be retrieved
Usage
To specify a NULL value, use the SetNull function.
The DECLARE statement is not executable and can be declared globally.
If your DBMS supports formats of FETCH other than the customary (and default) FETCH NEXT, you can specify FETCH FIRST, FETCH PRIOR, or FETCH LAST.
The FETCH and CLOSE statements in Format 3 are the same as in standard embedded SQL.
To declare a global, shared, or instance cursor or procedure, select Global Variables, Instance Variables, or Shared Variables on the Declare menu of the PowerScript painter. To declare a local cursor, click the Paint SQL button in the PainterBar.
For information about global, instance, shared, and local scope, see "Where to declare variables ".
以上是PB带的帮助
|