32.11. Library Functions
libecpg library primarily contains “hidden” functions that are used to implement the functionality expressed by the embedded SQL commands. But there are some functions that can usefully be called directly. Note that this makes your code unportable.
ECPGdebug(intturns on debug logging if called with the first argument non-zero. Debug logging is done on
on, FILE *
stream. The log contains all SQL statements with all the input variables inserted, and the results from the Postgres Pro server. This can be very useful when searching for errors in your SQL statements.
On Windows, if the ecpg libraries and an application are compiled with different flags, this function call will crash the application because the internal representation of the
FILEpointers differ. Specifically, multithreaded/single-threaded, release/debug, and static/dynamic flags should be the same for the library and all applications using that library.
ECPGget_PGconn(const char *returns the library database connection handle identified by the given name. If
connection_nameis set to
NULL, the current connection handle is returned. If no connection handle can be identified, the function returns
NULL. The returned connection handle can be used to call any other functions from libpq, if necessary.
It is a bad idea to manipulate database connection handles made from ecpg directly with libpq routines.
ECPGtransactionStatus(const char *returns the current transaction status of the given connection identified by
connection_name. See Section 30.2 and libpq's
PQtransactionStatus()for details about the returned status codes.
ECPGstatus(intreturns true if you are connected to a database and false if not.
lineno, const char*
NULLif a single connection is being used.