Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id CA34F9FC11F for ; Thu, 9 Aug 2007 05:43:16 -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 16068-09 for ; Thu, 9 Aug 2007 05:43:07 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from smtp.guitar.ocn.ne.jp (guitar.ocn.ne.jp [61.207.12.174]) by postgresql.org (Postfix) with ESMTP id 1D2999FB744 for ; Thu, 9 Aug 2007 05:43:07 -0300 (ADT) Received: from HP22720319231 (221x112x108x194.ap221.ftth.ucom.ne.jp [221.112.108.194]) by smtp.guitar.ocn.ne.jp (Postfix) with SMTP id 95288525D; Thu, 9 Aug 2007 17:43:05 +0900 (JST) Message-ID: <048b01c7da61$4eaf6970$c601a8c0@HP22720319231> From: "Hiroshi Saito" To: Cc: References: <1186593244.173056.317630@q75g2000hsh.googlegroups.com> <11710.1186623677@sss.pgh.pa.us> <1186645291.049698.75020@g4g2000hsf.googlegroups.com> Subject: Re: UPDATE with data at exec and CURRENT OF question Date: Thu, 9 Aug 2007 17:43:06 +0900 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3028 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/23 X-Sequence-Number: 9140 Hi. Sorry, very late reaction. First. > What version is capable of data_at_exec using SQLSetPos and also > support full cursor support ? > (not only forward cursors) > > I am still using 07.03.0200 on Mac OS X. I didn't get compiled the > 07.03.0260 version due to missing > pg_config. Can't you use the series of 08.02.xx, either? I think It should be cleared if there are some problems. > > 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. Yes , It is the function supported. > > What's wrong ? However, I can't immediately check the following code... Slight time is needed. I appreciate your perseverance. Regards, Hiroshi Saito > > 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); > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org