Submits a command to the server without waiting for the result(s).
1
is returned if the command was successfully dispatched and0
if not (in which case, use PQerrorMessage to get more information about the failure).After successfully calling
PQsendQuery
, callPQgetResult
one or more times to obtain the results.PQsendQuery
cannot be called again (on the same connection) untilPQgetResult
has returned a null pointer, indicating that the command is done.In pipeline mode, this function is disallowed.
type(c_ptr) :: conn
type(c_ptr) :: res
character(:), allocatable :: command
integer :: ires
conn = PQconnectdb("dbname=postgres")
(...error handling...)
ires = PQsendQuery(conn, command)
if (ires /= 1) then
print *, PQerrorMessage(conn)
end if
res = PQgetResult(conn)
do while (c_associated(res))
if (PQresultStatus(res) /= PGRES_TUPLES_OK) then
print *, PQerrorMessage(conn)
end if
print *, PQgetvalue(res, 0, 0)
call PQclear(res)
res = PQgetResult(conn)
end do
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(c_ptr), | intent(in) | :: | conn | |||
character(len=*), | intent(in) | :: | command |