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 4 – PB Docs 2018 – PowerBuilder Library

Dynamic SQL Format 4 – PB Docs 2018

Dynamic SQL Format 4

Description

Use this format to execute a SQL statement that produces a result
set in which the number of input parameters, or the number of result-set
columns, or both, are unknown 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.

DynamicDescriptionArea

The name of the DynamicDescriptionArea (usually
SQLDA).

If you need a DynamicDescriptionArea
variable other than SQLDA, you must declare it and instantiate
it with the CREATE statement before using it.

Usage

The DECLARE statement is not executable and can be defined
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.

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 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
.

Accessing attribute information

When a statement is described into a DynamicDescriptionArea, this
information is available to you in the attributes of that
DynamicDescriptionArea variable:

Information

Attribute

Number of input parameters

NumInputs

Array of input parameter types

InParmType

Number of output parameters

NumOutputs

Array of output parameter types

OutParmType

Setting and accessing parameter values

The array of input parameter values and the array of output
parameter values are also available. You can use the
SetDynamicParm function to set the values of an input parameter and the
following functions to obtain the value of an output parameter:

GetDynamicDate 

GetDynamicDateTime 

GetDynamicDecimal 

GetDynamicNumber 

GetDynamicString 

GetDynamicTime

For information about these functions, see

GetDynamicDate

GetDynamicDateTime

GetDynamicDecimal

GetDynamicNumber

GetDynamicString

GetDynamicTime.

Parameter values

The following enumerated datatypes are the valid values for the
input and output parameter types:

TypeBoolean!

TypeByte!

TypeDate!

TypeDateTime!

TypeDecimal!

TypeDouble!

TypeInteger!

TypeLong!

TypeLongLong!

TypeReal!

TypeString!

TypeTime!

TypeUInt!

TypeULong!

TypeUnknown!

Input parameters

You can set the type and value of each input parameter found in
the PREPARE statement. PowerBuilder populates the SQLDA attribute
NumInputs when the DESCRIBE is executed. You can use this value with the
SetDynamicParm function to set the type and value of a specific input
parameter. The input parameters are optional; but if you use them, you
should fill in all the values before executing the OPEN or EXECUTE
statement.

Output parameters

You can access the type and value of each output parameter found
in the PREPARE statement. If the database supports output parameter
description, PowerBuilder populates the SQLDA attribute NumOutputs when
the DESCRIBE is executed. If the database does not support output
parameter description, PowerBuilder populates the SQLDA attribute
NumOutputs when the FETCH statement is executed.

You can use the number of output parameters in the NumOutputs
attribute in functions to obtain the type of a specific parameter from
the output parameter type array in the OutParmType attribute. When you
have the type, you can call the appropriate function after the
FETCH statement to retrieve the output value.

Examples

Example 1

These statements assume you know that there will be only one
output descriptor and that it will be an integer. You can expand this
example to support any number of output descriptors and any datatype by
wrapping the CHOOSE CASE statement in a loop and expanding the CASE
statements:

Example 2

These statements assume you know there is one string input
descriptor and sets the parameter to MA:

Example 3

This example is 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