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

PQexecPrepared

Description

Sends a request to execute a prepared statement with given parameters and waits for the result.

Prototype

PGresult* PQexecPrepared(PGconn* conn, 
                         const char* stmtName, 
                         int nParams, 
                         const char* const* paramValues,
                         const int* paramLengths,
                         const int* paramFormats,
                         int resultFormat);

Parameters

Table 1 PQexecPrepared parameters

Keyword

Description

conn

Connection handle.

stmtName

stmt name, which can be set to "" or NULL to reference an unnamed statement. Otherwise, it must be the name of an existing prepared statement.

nParams

Parameter quantity.

paramValues

Actual values of parameters.

paramLengths

Actual data lengths of parameters.

NOTICE:

In the following cases, the parameter length is forcibly set to the corresponding value of paramLengths:

  • The parameter is in binary format.
  • The parameter is in text format and the value of force_no_truncation is 1.

In these cases, paramLengths cannot be empty, and the caller must ensure the correctness of the parameter length.

paramFormats

Parameter formats (text or binary).

resultFormat

Return result format (text or binary).

Return Values

PGresult pointers.