DbiQSetParams

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

DbiQSetParams

Return to chapter overview

C syntax

DBIResult DBIFN DbiQSetParams (hStmt, uFldDescs, paFldDescs, pRecBuf);

Delphi syntax

function DbiQSetParams (hStmt: hDBIStmt; uFldDescs: Word; paFldDescs: pFLDDesc; pRecBuff: Pointer): DBIResult stdcall;

Description

DbiQSetParams associates data with parameter markers embedded within a prepared query.

Parameters

hStmt                Type: hDBIStmt                (Input)
Specifies the statement handle.

uFldDescs                Type: UINT16                (Input)
Specifies the number of parameter field descriptors given.

paFldDescs                Type: pFLDDesc                (Input)
Pointer to the array of parameter field descriptors.

pRecBuf                Type: pBYTE                (Input)
Pointer to the client buffer containing data for the specified fields.

Usage

This function is used to set the value of parameter markers in a prepared query before the query execution.

The field descriptor array and record buffer is constructed by the client and passed to BDE, which uses each specified field, along with the record buffer, to locate the data and set the specified parameter. Each field may be either a BDE type or a driver type for the database that the query is prepared for.

Parameter markers are "?", ":name", or "~name" (tilde, used only with QBE queries). The field descriptor for a "?" parameter marker must contain no name, and must contain a field number that matches the position of the "?" marker within the query, beginning with marker number one. The field descriptor for a ":name" marker must contain the name of the marker, and a field number of zero.

Parameter settings are retained from statement execution to statement execution. However, all parameters must be set before execution can occur.

To bind BLOBs and strings longer than 255 characters you must use BLOBParamDesc to describe the parameter in a FLDDesc structure. Clients need to allocate and set up a BLOBParamDesc structure for each blob or long string that will be passed as a parameter. For BLOBs, iFldType in FLDDesc is set to fldBLOB and iSubType is set to fldstMEMO or fldstBINARY. For long strings, iFldType should be set to fldZSTRING and the length should specified in iUnits1 as normal. The BLOBParamDesc structure is copied into the parameter buffer at the specifed iOffset, then DbiQSetParams and DbiQExec are called as normal. You can determine if a field is a BLOB or long string by checking iUnits1. If iUnits1 is 1, it is a BLOB; if it is greater than one, it is a long string. This test does not work on servers that don't maintain a distinction between BLOBs and long strings, like Sybase.

DbiResult

Meaning

DBIERR_NONE

The value of parameter markers was successfully set.

DBIERR_OBJNOTFOUND

A field descriptor references a parameter marker that does not exist.

DBIERR_INVALIDHNDL

DbiQSetParams was called without first having called DbiQPrepare.

See also

DbiQExec, DbiQFree, DbiQPrepare, DbiQAlloc