Mimer SQL Programmer's Manual TOC PREV NEXT INDEX

Mimer Developer Site

www.mimer.com/developer


Describing Prepared Statements


Statements returning a result set and statements containing parameter markers can be described to obtain information about the number and data types of the parameters.

There are two forms of DESCRIBE:

Both forms of DESCRIBE use the object (prepared) form of the statement as an argument. The same statement may be described in both senses if necessary.

For example:

 exec sql BEGIN DECLARE SECTION;
 SQLA1    CHARACTER(128);
 MAXOCC   INTEGER;
 SOURCE   CHARACTER(255);
 exec sql END DECLARE SECTION;
 ...
 MAXOCC := 15;
 SQLA1 := "SQL_AREA_1";
 exec sql ALLOCATE DESCRIPTOR :SQLA1 WITH MAX 20;
 exec sql ALLOCATE DESCRIPTOR 'SQLA2' WITH MAX :MAXOCC;
 ...
 exec sql PREPARE OBJECT FROM :SOURCE;
 exec sql DESCRIBE OUTPUT OBJECT USING SQL DESCRIPTOR :SQLA1;
 exec sql DESCRIBE INPUT OBJECT USING SQL DESCRIPTOR 'SQLA2';
 ...
 

DESCRIBE places information about the prepared statement in the SQL descriptor areas. See SQL Descriptor Area for a description of the SQL descriptor area.

The contents of the SQL descriptor area is read with the GET DESCRIPTOR statement and updated with the SET DESCRIPTOR statement.

Describing Output Variables

The items in the result set for a statement are described with the DESCRIBE OUTPUT statement. The keyword OUTPUT may be omitted.

The DESCRIBE OUTPUT statement shows:

Describing Input Variables

The DESCRIBE INPUT statement is used to describe parameter markers.

The value of the COUNT field of the SQL descriptor area indicates the number of parameter markers in the statement (a value of zero indicates no input parameters). A value greater than that specified in "WITH MAX..." indicates that the allocated SQL descriptor area is too small and the describe operation will not be performed. This situation is handled as described above for DESCRIBE OUTPUT.

Note: If the prepared statement is a call to a stored procedure that uses parameter markers, these will be described by the DESCRIBE INPUT statement. This is regardless of how the formal parameter is specified in the procedure definition. Whether the parameter is IN, INOUT or OUT can be seen from the PARAMETER_MODE field in the descriptor area.


Upright Database Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40
dbtechnology@upright.se
Mimer SQL Programmer's Manual TOC PREV NEXT INDEX