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

PQsendQueryParams

Description

Commits a command with separated parameters to the server without waiting for the result.

Prototype

int PQsendQueryParams(PGconn* conn, const char* command, int nParams, const Oid* paramTypes,
    const char* const* paramValues, const int* paramLengths, const int* paramFormats, int resultFormat);

Parameters

Table 1 PQsendQueryParams parameters

Keyword

Description

conn

Points to the object pointer that contains the connection information.

command

Query string to be executed.

nParams

Parameter quantity.

paramTypes

Parameter type.

paramValues

Parameter value.

paramLengths

Parameter length.

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 format.

resultFormat

Result format.

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

This function is equivalent to PQsendQuery. The only difference is that query parameters can be specified separately from the query string. The parameter processing of this function is similar to that of PQexecParams. It cannot work on connections using protocol v2.0, and it allows only one command to appear in the query string.