Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Dynamic SQL Format 3 – PB Docs 2019 – PowerBuilder Library

Dynamic SQL Format 3 – PB Docs 2019

Dynamic SQL Format 3

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

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 local cursor or procedure, open the script in the
Script view and select Paste SQL from the PainterBar or the
Edit>Paste Special menu. To declare a global, instance, or shared
cursor or procedure, select Declare from the first drop-down list in the
Script view, and select Global Variables, Instance Variables, or Shared
Variables from the second drop-down list. Then, select Paste SQL.

For information about global, instance, shared, and local scope,
see Where to declare
variables
.

Examples

Example 1

These statements associate a cursor named my_cursor with SQLSA,
prepare a SELECT statement in SQLSA, open the cursor, and return the
employee ID in the current row into the PowerScript variable
Emp_id_var:

You can loop through the cursor as you can in embedded static
SQL.

Example 2

These statements associate a cursor named my_cursor with SQLSA,
prepare a SELECT statement with one parameter in SQLSA, open the cursor,
and substitute the value of the variable Emp_state_var for the parameter
in the SELECT statement. The employee ID in the active row is returned
into the PowerBuilder variable Emp_id_var:

Example 3

These statements perform the same processing as the preceding
example but use a database stored procedure called Emp_select:

Example 4

These statements are for a stored procedure with a return value
for a SQL Native Client (SNC) connection:


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x