GetDynamicDate PowerScript function
Description
Obtains data of type Date from the DynamicDescriptionArea
after you have executed a dynamic SQL statement.
Restriction
You can use this function only after
executing Format 4 dynamic SQL statements.
Syntax
|
1 |
<span>DynamicDescriptionArea</span><span>.GetDynamicDate</span> ( <span>index</span> ) |
|
Argument |
Description |
|---|---|
|
DynamicDescriptionArea |
The name of the DynamicDescriptionArea, |
|
index |
An integer identifying the output parameter descriptor |
Return Values
Date. Returns the Date data
in the output parameter descriptor identified by index in DynamicDescriptionArea.
Returns 1900-01-01 if an
error occurs. If any argument’s value is null, GetDynamicDate returns null.
Usage
After you fetch data using Format 4 dynamic SQL statements, the DynamicDescriptionArea,
usually SQLDA, contains
information about the data retrieved. The SQLDA property
NumOutputs specifies the number of data descriptors returned. The
property array OutParmType contains values of the ParmType enumerated
datatype specifying the datatype of each value returned.
Use GetDynamicDate when the value of OutParmType
is TypeDate! for the value in the array that you want to retrieve.
Examples
These statements set Today to the Date data
in the second output parameter descriptor:
|
1 |
Date Today |
|
1 |
Today = <span>GetDynamicDate</span>(SQLDA, 2) |
If you have executed Format 4 dynamic SQL statements, data is stored in
the DynamicDescriptionArea. This example finds out the datatype
of the stored data and uses a CHOOSE CASE statement
to assign it to local variables.
If the SELECT statement is:
|
1 |
SELECT emp_start_date FROM employee; |
then the code at CASE Typedate! will
be executed.
For each case, other processing could assign the value to
a DataWindow so that the value would not be overwritten when another
value has the same ParmType:
|
1 |
Date Datevar |
|
1 |
Time Timevar |
|
1 |
DateTime Datetimevar |
|
1 |
Double Doublevar |
|
1 |
String Stringvar |
|
1 |
|
1 |
FOR n = 1 to SQLDA.NumOutputs |
|
1 |
CHOOSE CASE SQLDA.OutParmType[n] |
|
1 |
CASE TypeString! |
|
1 |
Stringvar = SQLDA.GetDynamicString(n) |
|
1 |
... // Other processing |
|
1 |
CASE TypeDecimal!, TypeDouble!, & |
|
1 |
TypeInteger!, TypeLong!, & |
|
1 |
TypeReal!, TypeBoolean! |
|
1 |
Doublevar = SQLDA.GetDynamicNumber(n) |
|
1 |
... // Other processing |
|
1 |
CASE TypeDate! |
|
1 |
Datevar = SQLDA.<span>GetDynamicDate</span>(n) |
|
1 |
... // Other processing |
|
1 |
CASE TypeDateTime! |
|
1 |
Datetimevar = SQLDA.GetDynamicDateTime(n) |
|
1 |
... // Other processing |
|
1 |
CASE TypeTime! |
|
1 |
Timevar = SQLDA.GetDynamicTime(n) |
|
1 |
... // Other processing |
|
1 |
CASE ELSE |
|
1 |
MessageBox("Dynamic SQL", & |
|
1 |
"datatype unknown.") |
|
1 |
END CHOOSE |
|
1 |
NEXT |