July 2005
Intermediate to advanced
1032 pages
27h 10m
English
Now that you understand the basic architecture of the ODBC API and you have defined a PostgreSQL data source, let's look at some sample code. This first client application connects to a database and then exits. Listing 12.1 provides an example that is much more complex than the sample clients in earlier chapters—ODBC is a complex API.
1 /* client1.c */ 2 3 #include <sql.h> 4 #include <sqlext.h> 5 6 #include <stdio.h> 7 8 typedef enum { FALSE, TRUE } bool; 9 10 int main( int argc, char * argv[] ) 11 { 12 SQLRETURN result; 13 SQLHENV envHandle; 14 SQLHDBC conHandle; 15 16 SQLAllocHandle( SQL_HANDLE_ENV, 17 SQL_NULL_HANDLE, 18 &envHandle ); 19 20 SQLSetEnvAttr( envHandle, 21 SQL_ATTR_ODBC_VERSION, ... |
Read now
Unlock full access