Previous Topic

Next Topic

Queries, Parameters, and Query Data Correlation

Use this section as a guide for entering SQL statement parameters with IIapi_query(). It also provides valid column and data types for parameters when sending data formats with IIapi_setDescriptor().

Previous Topic

Next Topic

Queries and Parameters

Each SQL statement invoked with IIapi_query() may or may not have query parameters associated with it. In general, query input parameters are needed when:

The table in this section lists the query types for SQL statements that can have query parameters associated with them. The first three columns provide information for sending an SQL statement to the DBMS Server. The Query Type column lists valid entries for the qy_queryType parameter of IIapi_query(). The Query Text? column indicates whether a query text entry is required in the qy_queryText parameter of IIapi_query(). Query text is not required for some SQL statements because OpenAPI can construct the query text based solely on the query type.

When SQL statements require query parameters, the application invokes IIapi_query() and then enters the parameters in subsequent calls to IIapi_setDescriptor() and IIapi_putParms(). The Query Input Parameters column indicates what parameters are needed.

Note: For a description of SQL statements and their parameters, see the SQL Reference Guide.

When an application calls IIapi_getQueryInfo(), it receives information about the status of a previously-invoked SQL statement. For some statements, IIapi_getQueryInfo() also returns available response data in the gq_mask parameter. This information is given for applicable SQL statements in the Result Parameters column of the table.

Query Type

Query Text?

Query Input Parameters

Result Parameters

API_QT_EXEC

Yes *

[dynamic parameter values]

 

API_QT_OPEN

Yes *

[cursor name]
[dynamic parameter values]

IIAPI_GQ_CURSOR

API_QT_CURSOR_
DELETE

Yes *

Cursor ID

 

API_QT_CURSOR_
UPDATE

Yes *

Cursor ID
[parameter values]

IIAPI_GQ_TABLE_KEY or
IIAPI_GQ_OBJECT_KEY

API_QT_DEFINE_
REPEAT_QUERY

Yes *

[repeat query ID]
[repeat query parameters]

IIAPI_GQ_REPEAT_
QUERY_ID

API_QT_EXEC_
REPEAT_QUERY

No

Repeat query handle
[repeat query parameters]

 

API_QT_EXEC_
PROCEDURE

No

Procedure name or
procedure ID
[procedure owner]
[procedure parameters]

IIAPI_GQ_PROCEDURE_
ID

IIAPI_GQ_PROCEDURE_RET

API_QT_QUERY

Yes

[parameter values]

 

API_QT_SELECT_
SINGLETON

Yes

[parameter values]

 

* The query syntax for these statements differs from that used in embedded SQL. See SQL Syntax.

Previous Topic

Next Topic

Query Data Correlation

When an application calls IIapi_setDescriptor() to send information to the DBMS Server about parameter formats, it should make sure that the sd_descriptor parameter contains the appropriate column type and data type for each query parameter of an SQL statement.

The following table provides query parameters and their corresponding ds_columnType and ds_dataType values in the API_DESCRIPTOR structure:

Query Parameters

Descriptor Column Type

Data Type

Cursor name

IIAPI_COL_SVCPARM

IIAPI_CHA_TYPE

Cursor ID

IIAPI_COL_SVCPARM

IIAPI_APIHNDL_TYPE

Procedure ID

IIAPI_COL_SVCPARM

IIAPI_HNDL_TYPE

Procedure name

IIAPI_COL_SVCPARM

IIAPI_CHA_TYPE

Procedure owner

IIAPI_COL_SVCPARM

IIAPI_CHA_TYPE

Procedure parameters

IIAPI_COL_PROCPARM
or IIAPI_COL_
PROCBYREFPARM
IIAPI_COL_PROCINPARM
IIAPI_COL_PROCOUTPARM
IIAPI_COL_PROCINOUTPARM

Any of the Ingres data types in Ingres Data Types the "Data Types" appendix

Parameter values

IIAPI_COL_QPARM

Any of the Ingres data types in Ingres Data Types the "Data Types" appendix

Repeat query ID

IIAPI_COL_SVCPARM
IIAPI_COL_SVCPARM
IIAPI_COL_SVCPARM

IIAPI_INT_TYPE
IIAPI_INT_TYPE
IIAPI_CHA_TYPE

Repeat query handle

IIAPI_COL_SVCPARM

IIAPI_APIHNDL_TYPE

Repeat query parameters

IIAPI_COL_QPARM

Any of the Ingres data types in Ingres Data Types the "Data Types" appendix

Dynamic parameter values

IIAPI_COL_QPARM

Any of the Ingres data types in Ingres Data Types the "Data Types" appendix


© 2007 Ingres Corporation. All rights reserved.