Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 8F0E09FC19E for ; Thu, 9 Aug 2007 04:41:37 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 58815-01-2 for ; Thu, 9 Aug 2007 04:41:33 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 398009FC197 for ; Thu, 9 Aug 2007 04:41:34 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 216A431422; Thu, 9 Aug 2007 09:41:32 +0200 (MET DST) From: "lothar.behrens@lollisoft.de" X-Newsgroups: pgsql.interfaces.odbc Subject: Re: UPDATE with data at exec and CURRENT OF question Date: Thu, 09 Aug 2007 00:41:31 -0700 Organization: http://groups.google.com Lines: 102 Message-ID: <1186645291.049698.75020@g4g2000hsf.googlegroups.com> References: <1186593244.173056.317630@q75g2000hsh.googlegroups.com> <11710.1186623677@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Complaints-To: groups-abuse@google.com In-Reply-To: <11710.1186623677@sss.pgh.pa.us> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; de-de) AppleWebKit/312.8.1 (KHTML, like Gecko) Safari/312.6,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 jedi.behrens.de:3128 (squid/2.5.STABLE5) Complaints-To: groups-abuse@google.com Injection-Info: g4g2000hsf.googlegroups.com; posting-host=87.180.4.254; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 To: pgsql-odbc@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200708/21 X-Sequence-Number: 9138 Tom Lane schrieb: > "lothar.behrens@lollisoft.de" writes: > > UPDATE "Kontakte" set "Notiz" = ? WHERE CURRENT OF SQL_CUR0x1321f670 > > > Does PostgreSQL not support this syntax ? > > No. > > 8.3 will, FWIW. So then I tried the following code, but I get SQLSTATE=01001 and not the expected retval=SQL_NEED_DATA. I tried to use SQL_FETCH_ABSOLUTE to the current cursor position, but that seems not to help. What's wrong ? Thanks, Lothar #define LB_BLOCKSIZE 10 // Forcing usage of SQLPutData // hstmt is initialized SQLRETURN rc, retcode; SQLCHAR BinaryPtr[LB_BLOCKSIZE]; void* tempBuffer; long remainingsize; SQLINTEGER BinaryLenOrIndCurrentOf; SQLINTEGER BinaryLenOrInd; retcode = SQLAllocStmt(hdbc, &hupdatestmt); /* Statement handle */ retcode = SQLSetStmtOption(hupdatestmt, SQL_ATTR_CONCURRENCY, SQL_CONCUR_ROWVER); retcode = SQLSetStmtOption(hupdatestmt, SQL_CURSOR_TYPE, SQL_CURSOR_KEYSET_DRIVEN); value = "Hallo duda."; // 12 characters including 0 remainingsize = 12; BinaryLenOrInd = 12; BinaryLenOrIndCurrentOf = strlen("SQL_CURS0x012345678")+1; rc = SQLBindCol(hstmt, column, SQL_C_BINARY, (void *)BinaryPtr, 0, &BinaryLenOrIndCurrentOf); memcpy(BinaryPtr, cursorname, BinaryLenOrIndCurrentOf); retcode = SQLSetPos(hstmt, 1, SQL_UPDATE, SQL_LOCK_NO_CHANGE); retcode = SQLBindCol(hstmt, column, SQL_C_BINARY, NULL, 0, 0); // Force to reread current cursor data retcode = SQLExtendedFetch(hstmt, SQL_FETCH_ABSOLUTE, pos, &RowsFetched, &RowStat[0]); tempBuffer = value; BinaryLenOrInd = 12; remainingsize = 12; if (value->getSize() <= LB_BLOCKSIZE) { memcpy(BinaryPtr, tempBuffer, value->getSize()); } else { memcpy(BinaryPtr, tempBuffer, LB_BLOCKSIZE); } char* update_query = "UPDATE \"Kontakte\" SET \"Note\" = ? WHERE \"Note\" LIKE 'SQL_CURS0x012345678%'"; retcode = SQLPrepare(hupdatestmt, update_query, SQL_NTS); retcode = SQLBindParameter(hupdatestmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, 0, 0, (SQLPOINTER) &BinaryPtr, 0, &BinaryLenOrInd); retcode = SQLExecute(hupdatestmt); long iteration = 0; if ((retcode != SQL_SUCCESS) && (retcode != SQL_NEED_DATA)) { printf("Execute query failed.\n"); // <<== Happens (SQLSTATE=01001) } if (retcode == SQL_NEED_DATA) { retcode = SQLParamData(hupdatestmt, (void **) &BinaryPtr); while(retcode == SQL_NEED_DATA) { tempBuffer += LB_BLOCKSIZE; remainingsize -= LB_BLOCKSIZE; if (remainingsize <= LB_BLOCKSIZE) memcpy(BinaryPtr, tempBuffer, remainingsize); else memcpy(BinaryPtr, tempBuffer, LB_BLOCKSIZE); retcode = SQLPutData(hupdatestmt, BinaryPtr, SQL_NTS); retcode = SQLParamData(hupdatestmt, (void **) &BinaryPtr); } } SQLFreeStmt(hupdatestmt, SQL_DROP);