Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 63C1DA5712 for ; Wed, 9 Nov 2011 23:46:38 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 58171-10 for ; Thu, 10 Nov 2011 03:46:31 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sd.tpf.co.jp (sd.tpf.co.jp [210.161.239.34]) by mail.postgresql.org (Postfix) with SMTP id 8F8FDA5711 for ; Wed, 9 Nov 2011 23:46:30 -0400 (AST) Received: (qmail 26017 invoked by uid 512); 10 Nov 2011 03:46:29 -0000 Received: from unknown (HELO ?100.0.32.108?) (100.0.32.108) by sd2.tpf-fw-c.co.jp with SMTP; 10 Nov 2011 03:46:29 -0000 Message-ID: <4EBB4912.90707@tpf.co.jp> Date: Thu, 10 Nov 2011 12:46:26 +0900 From: Hiroshi Inoue User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; ja; rv:1.9.2.24) Gecko/20111103 Thunderbird/3.1.16 MIME-Version: 1.0 To: BGoebel CC: pgsql-odbc@postgresql.org Subject: Re: FETCH LAST is returning "no data" after a Cursor Update References: <1320855055219-4978166.post@n5.nabble.com> In-Reply-To: <1320855055219-4978166.post@n5.nabble.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.101 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.201 X-Spam-Level: X-Archive-Number: 201111/25 X-Sequence-Number: 10743 Hi, (2011/11/10 1:10), BGoebel wrote: > Hi All, > > this is a bug we have found when testing the unreleased psqlodbc30a.dll > 9.00.0311. > > The attached example shows an error using a SELECT + CursorUpdate + FETCH > LAST. > After a SELECT we are updating the column name on the first row via > SQLSetPos and SQLEndtran. > Executing a Fetch LAST will returning 100/No Data > > Sending a COMMIT via ExecuteSQL seems to work, but i do not know if that is > a really a reliable solution. Could you please retry the drivers on testing for 9.0.0311? regards, Inoue, Hiroshi > regards > > BGoebel > > > > Tested with pg 9.1 / psqlodbc30a.dll 9.00.0311 / Delphi7.0 > ----------------------------------------------- > Used SQL Data/Definition > > drop table if exists customers; > create table customers(nr integer, name varchar(100)); > insert into customers(nr, name) VALUES(1, 'Mayer'); > insert into customers(nr, name) VALUES(2, 'Miller'); > insert into customers(nr, name) VALUES(3, 'Smith'); > > ----------------------------------------------- > fEnvHandle := 0; > fConnectHandle := 0; > > aRes := SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, fEnvHandle); > aRes := SQLAllocHandle(SQL_HANDLE_DBC, fEnvHandle, fConnectHandle); > > aSqlSmallint := 0; > aConnectString := > 'Driver={PostgreSQL};Server=127.0.0.1;Port=5432;Database=postgres' + > > ';Uid=postgres;Pwd=mypwd;UpdatableCursors=1;usedeclarefetch=1;fetch=50'; > > aRes := SQLDriverConnect(fConnectHandle, > GetDesktopWindow, > @aConnectString[1], > length(aConnectString), > nil, > 0, > aSqlSmallint, > 0); > //switchin AUTOCOMMIT off > aRes := SQLSetConnectAttr(fConnectHandle, > SQL_ATTR_AUTOCOMMIT, > pointer(SQL_AUTOCOMMIT_OFF), > sizeof(SQL_AUTOCOMMIT_OFF)); > aRes:= SQLAllocHandle(SQL_HANDLE_STMT, fConnectHandle, hStmtSelect); > aRes:= SQLAllocHandle(SQL_HANDLE_STMT, fConnectHandle, hStmtUpdate); > > // Cursor : KeySetDriven + SQL_CONCUR_ROWVER(=updatable) > aRes:= sqlSetStmtAttr(hStmtSelect, > SQL_ATTR_CONCURRENCY, > pointer(SQL_CONCUR_ROWVER), > sizeof(SQLSmallint)); > aRes:= sqlSetStmtAttr(hStmtSelect, > SQL_ATTR_CURSOR_TYPE, > pointer(SQL_CURSOR_KEYSET_DRIVEN), > sizeof(SQLSmallint)); > // Select ... > aRes := SQLExecDirect(hstmtSelect, > pchar('SELECT name FROM customers order by nr'), > SQL_NTS); > // fetch will read name > aRes:= SQLBindCol(hstmtSelect, 1, SQL_C_CHAR, @szName[1], 50, cbName); > > // fetching/reading the first row > aRow := 1; > aRes := SQLFetchScroll(hStmtSelect, SQL_FETCH_NEXT, 0); > > > // Changing data. Doing so, every time i call this snippet, the value will > be changed > szName[0]:=Chr(cbName); > IF szName[1]<'a' > THEN > szName := 'anyname' > ELSE > szName := 'ANYNAME'; > cbName:=Length(szName); > // UPDATE data > aRes := SQLSetPos(hstmtSelect, > 1, > SQL_UPDATE, > SQL_LOCK_UNLOCK ); > > // Make changes visible to other users --> commit > // aRes:=SQLExecDirect(hstmtUpdate, 'commit', SQL_NTS); //<-- next > SQLFetchScroll will work > aRes := SQLEndTran(SQL_HANDLE_DBC, fConnectHandle, SQL_COMMIT); //<-- next > SQLFetchScroll will return 100 > > aRes := SQLFetchScroll(hStmtSelect, > SQL_FETCH_LAST, > 0); > Assert(aRes = 0); > > > aRow:=100; > aRes := SQLFetchScroll(hStmtSelect, > SQL_FETCH_ABSOLUTE, > arow); > Assert(aRes = 0);