PostgreSQL 9.4.1 Documentation | |||
---|---|---|---|
Prev | Up | Chapter 33.ECPG - EmbeddedSQL in C | Next |
33.11. Library Functions
Thelibecpg 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(inton, FILE *stream)
turns on debug logging if called with the first argument non-zero. Debug logging is done onstream. The log contains allSQL statements with all the input variables inserted, and the results from thePostgreSQL server. This can be very useful when searching for errors in yourSQL statements.Note: On Windows, if theecpg libraries and an application are compiled with different flags, this function call will crash the application because the internal representation of theFILE pointers 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 *connection_name)
returns the library database connection handle identified by the given name. Ifconnection_name is set toNULL, the current connection handle is returned. If no connection handle can be identified, the function returnsNULL. The returned connection handle can be used to call any other functions fromlibpq, if necessary.Note: It is a bad idea to manipulate database connection handles made fromecpg directly withlibpq routines.
ECPGtransactionStatus(const char *connection_name)
returns the current transaction status of the given connection identified byconnection_name. SeeSection 31.2 and libpq'sPQtransactionStatus()
for details about the returned status codes.ECPGstatus(intlineno, const char*connection_name)
returns true if you are connected to a database and false if not.connection_name can beNULL if a single connection is being used.