PQprepare Interface

public interface PQprepare

Contents


Module Procedures

private function PQprepare_int32(conn, stmtName, query, nParams, paramTypes) result(res)

Submits a request to create a prepared statement with the given parameters, and waits for completion.

PQprepare creates a prepared statement for later execution with PQexecPrepared. This feature allows commands to be executed repeatedly without being parsed and planned each time; see PREPARE for details.

The function create a prepared statement named stmtName from the query string, which must contain a single SQL command. stmtName can be "" to create an unnamed statement, in which case any pre-existing unnamed statement is automatically replaced; otherwise it is an error if the statement name is already defined in the current session. If any parameters are used, they are referred to in the as $1, $2, etc. nParams is the number of parameters for which types are pre-specified in the array paramTypes. paramTypes specifies, by OID, the data types to be assigned to the parameter symbols. If any particuler element in the paramTypes array is zero, the server assigns a data type to the parameter symbol in the same way it would do for an untyped literal string. Also, the query can use parameter symbols with the numbers higher than nParams; data types will be inferred for these symbols as well. (See PQdescribePrepared) for a means to find out what data types were inffered.)

As with [[PQexec]], the result is normally a PGresult object whose contents indicate server-side success or failure. A null result indicates out-of-memory or inability to send to the command at all. Use PQerrorMessage to get more information about such errors.

cf. PostgreSQL Documentation

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: conn
character(len=*), intent(in) :: stmtName
character(len=*), intent(in) :: query
integer(kind=int32), intent(in) :: nParams
integer(kind=int32), intent(in) :: paramTypes(:)

Return Value type(c_ptr)

private function PQprepare_int64(conn, stmtName, query, nParams, paramTypes) result(res)

Submits a request to create a prepared statement with the given parameters, and waits for completion.

PQprepare creates a prepared statement for later execution with PQexecPrepared. This feature allows commands to be executed repeatedly without being parsed and planned each time; see PREPARE for details.

The function create a prepared statement named stmtName from the query string, which must contain a single SQL command. stmtName can be "" to create an unnamed statement, in which case any pre-existing unnamed statement is automatically replaced; otherwise it is an error if the statement name is already defined in the current session. If any parameters are used, they are referred to in the as $1, $2, etc. nParams is the number of parameters for which types are pre-specified in the array paramTypes. paramTypes specifies, by OID, the data types to be assigned to the parameter symbols. If any particuler element in the paramTypes array is zero, the server assigns a data type to the parameter symbol in the same way it would do for an untyped literal string. Also, the query can use parameter symbols with the numbers higher than nParams; data types will be inferred for these symbols as well.

As with PQexec, the result is normally a PGresult object whose contents indicate server-side success or failure. A null result indicates out-of-memory or inability to send to the command at all. Use PQerrorMessage to get more information about such errors.

cf. PostgreSQL Documentation

cf. PostgreSQL Documentation

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: conn
character(len=*), intent(in) :: stmtName
character(len=*), intent(in) :: query
integer(kind=int32), intent(in) :: nParams
integer(kind=int64), intent(in) :: paramTypes(:)

Return Value type(c_ptr)