Updated on 2025-05-29 GMT+08:00

PQsendPrepare

Description

Sends a request to create a prepared statement with given parameters, without waiting for completion.

Prototype

int PQsendPrepare(PGconn* conn, const char* stmtName, const char* query, int nParams, const Oid* paramTypes);

Parameters

Table 1 PQsendPrepare parameters

Keyword

Description

conn

Object pointer that contains the connection information.

stmtName

Name of a prepared statement to be executed.

query

Query string to be executed.

nParams

Parameter quantity.

paramTypes

Array of the parameter type.

Return Values

int indicates the execution result. 1 indicates successful execution and 0 indicates an execution failure. The failure cause is stored in conn->errorMessage.

Precautions

PQsendPrepare is an asynchronous version of PQprepare. If it can dispatch a request, 1 is returned. Otherwise, 0 is returned. After a successful calling of PQsendPrepare, call PQgetResult to check whether the server successfully created the prepared statement. PQsendPrepare parameters are handled in the same way as PQprepare parameters. Like PQprepare, PQsendPrepare cannot work on connections using protocol v2.0.

Examples

For details, see Typical Application Development Examples.