Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id C6DFC4A7475 for ; Tue, 8 Nov 2011 23:52:00 -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 94503-07 for ; Wed, 9 Nov 2011 03:51:51 +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 960164A7474 for ; Tue, 8 Nov 2011 23:51:50 -0400 (AST) Received: (qmail 7798 invoked by uid 512); 9 Nov 2011 03:51:50 -0000 Received: from unknown (HELO ?100.0.32.108?) (100.0.32.108) by sd2.tpf-fw-c.co.jp with SMTP; 9 Nov 2011 03:51:50 -0000 Message-ID: <4EB9F8D6.9080108@tpf.co.jp> Date: Wed, 09 Nov 2011 12:51:50 +0900 From: Hiroshi Inoue User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; ja; rv:1.9.2.23) Gecko/20110920 Thunderbird/3.1.15 MIME-Version: 1.0 To: BGoebel CC: pgsql-odbc@postgresql.org Subject: Re: Fetch absolute returns OK when fetching a nonexistent row References: <1320678693054-4971382.post@n5.nabble.com> In-Reply-To: <1320678693054-4971382.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/20 X-Sequence-Number: 10738 Hi, (2011/11/08 0:11), BGoebel wrote: > Hi All, > > Once again i need your help. > > The attached example shows an error using a simple ODBC SELECT + FETCH. > Fetching the (non existing) 100th row results in 0 (=ok) instead of 100(no > data). > > The error seems to be depend on the FETCH parameter of the connection > string: > When using ...;Fetch=3 in the connection string i get the right resultcode > 100. > A previous FETCH NEXT seems to help too, but i think we can not rely on > this. > > any help would be appreciated Could you please try the drivers on testing for 9.0.0311 at http://www.ne.jp/asahi/inocchichichi/entrance/psqlodbc/ ? regards, Inoue, Hiroshi > best regards > > > Tested with pg 9.1 / odbcDriver 9.00.0310 / Delphi7.0 > ----------------------------------------------- > > PROCEDURE FetchAbsoluteTest; > > Var aRes:Integer; > hStmtSelect,hstmtUpdate,fEnvHandle,fConnectHandle:SQLHandle; > szName:ShortString; > cbName:SQLInteger; > aScroll,aSQLSmallInt:SQLSmallInt; > aConnectString:String; > aRow:Cardinal; > Begin > > (* > tabledefinition and data used in this case: > > drop table if exists customers; > create table customers(nr integer, name varchar(100)); > insert into customers(nr, name) VALUES(1, 'Mayers'); > 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=1'; > > 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); > > // 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'), > SQL_NTS); > // fetch will read the column "name" > aRes:= SQLBindCol(hstmtSelect, 1, SQL_C_CHAR, @szName[1], 50, cbName); > > //fetching absolute a nonexisting row > aRes := SQLFetchScroll(hStmtSelect, SQL_FETCH_ABSOLUTE, 100); > Assert(aRes = 100); > END;