Submits a request to create a prepared statement with the given parameters, and waits for completion.
PQprepare
creates a prepared statement for later execution withPQexecPrepared
. 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 thequery
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 arrayparamTypes
.paramTypes
specifies, by OID, the data types to be assigned to the parameter symbols. If any particuler element in theparamTypes
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 thannParams
; 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 aPGresult
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. UsePQerrorMessage
to get more information about such errors.
Type | Intent | Optional | 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(:) |
Submits a request to create a prepared statement with the given parameters, and waits for completion.
PQprepare
creates a prepared statement for later execution withPQexecPrepared
. 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 thequery
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 arrayparamTypes
.paramTypes
specifies, by OID, the data types to be assigned to the parameter symbols. If any particuler element in theparamTypes
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 thannParams
; data types will be inferred for these symbols as well.As with
PQexec
, the result is normally aPGresult
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. UsePQerrorMessage
to get more information about such errors.
Type | Intent | Optional | 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(:) |