Re: VARCHAR, CHAR types changed ? - Mailing list pgsql-odbc
From | Dave Page |
---|---|
Subject | Re: VARCHAR, CHAR types changed ? |
Date | |
Msg-id | E7F85A1B5FF8D44C8A1AF6885BC9A0E4E7E390@ratbert.vale-housing.co.uk Whole thread Raw |
In response to | VARCHAR, CHAR types changed ? ("lothar.behrens@lollisoft.de" <lothar.behrens@lollisoft.de>) |
Responses |
Re: VARCHAR, CHAR types changed ?
|
List | pgsql-odbc |
> -----Original Message----- > From: pgsql-odbc-owner@postgresql.org > [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of > lothar.behrens@lollisoft.de > Sent: 25 November 2005 13:21 > To: pgsql-odbc@postgresql.org > Subject: Re: [ODBC] VARCHAR, CHAR types changed ? > > I have tried to use ANSI driver. It crashes :-( > > My code to connect and setup a statement looks like this: > <snip code> > > The code is simple console based, but my database classes encapsulate > all ODBC > CLI calls. The internal statement handle is reused. The table get's > created and filled. > > Any ideas ? Well, I've tried the code below which is roughly as close as I can get to what you posted (not having your query class), and it SQLExecDirect's just fine here. Any thoughts on what might be significantly different here?: Regards, Dave. #include <windows.h> #include <sqlext.h> #include <stdio.h> int main(void) { HENV henv = NULL; // Env Handle from SQLAllocEnv() HDBC hdbc = NULL; // Connection handle HSTMT hstmt = NULL; // Statement handle UCHAR DSN[SQL_MAX_DSN_LENGTH] = "ansi"; // Data Source Name buffer UCHAR user[64] = "postgres"; // User ID buffer UCHAR* passwd = NULL; // Password buffer SQLAllocEnv (&henv); SQLAllocConnect (henv, &hdbc); SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*) SQL_OV_ODBC3, 0); SQLSetConnectAttr(hdbc, SQL_ATTR_ODBC_CURSORS, SQL_CUR_USE_IF_NEEDED, 0); SQLConnect(hdbc, DSN, SQL_NTS, user, SQL_NTS, passwd, SQL_NTS); SQLSetConnectOption(hdbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_ON); SQLAllocStmt (hdbc, &hstmt); SQLSetStmtOption(hstmt, SQL_ATTR_CONCURRENCY, SQL_CONCUR_ROWVER); SQLSetStmtOption(hstmt, SQL_CURSOR_TYPE, SQL_CURSOR_KEYSET_DRIVEN); UCHAR buf1[] = "create table regressiontest (" "test char(100) DEFAULT 'Nothing',\n" "btest bool DEFAULT false, " "btest1 bool DEFAULT false" ");"; UCHAR buf2[] = "insert into regressiontest (test) values('Nix')"; UCHAR buf3[] = "insert into regressiontest (btest) values(true)"; UCHAR buf4[] = "insert into regressiontest (btest1) values(true)"; SQLExecDirect(hstmt, buf1, sizeof(buf1)); SQLExecDirect(hstmt, buf2, sizeof(buf2)); SQLExecDirect(hstmt, buf3, sizeof(buf3)); SQLExecDirect(hstmt, buf4, sizeof(buf4)); // This statement crashes inside SQLExecDirect(...) UCHAR buf5[] = "select test, btest, btest1 from regressiontest"; SQLExecDirect(hstmt, buf5, sizeof(buf5)); // UCHAR buf6[] = "drop table regressiontest"; // SQLExecDirect(hstmt, buf6, sizeof(buf6)); // Free the allocated statement handle SQLFreeStmt (hstmt, SQL_DROP); // Free the allocated connection handle SQLFreeConnect (hdbc); // Free the allocated ODBC environment handle SQLFreeEnv (henv); return 0; }
pgsql-odbc by date: