Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UfHGQ-0005rM-9p for pgsql-odbc@arkaria.postgresql.org; Wed, 22 May 2013 22:12:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UfHGP-0001Tc-PL for pgsql-odbc@arkaria.postgresql.org; Wed, 22 May 2013 22:12:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UfHGP-0001TW-0s for pgsql-odbc@postgresql.org; Wed, 22 May 2013 22:12:05 +0000 Received: from www.courier-mta.com ([216.254.115.190]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UfHGJ-0008DP-Ls for pgsql-odbc@postgresql.org; Wed, 22 May 2013 22:12:04 +0000 Received: from monster.email-scan.com (monster.email-scan.com [::ffff:192.168.0.2]) (TLS: TLSv1/SSLv3,256bits,AES256-SHA) by www.courier-mta.com with ESMTPS; Wed, 22 May 2013 18:11:57 -0400 id 000000000006018F.00000000519D42AD.00005484 Received: from monster.email-scan.com (localhost [127.0.0.1]) (IDENT: uid 1000) by monster.email-scan.com with ESMTP; Wed, 22 May 2013 18:11:57 -0400 id 0000000000010087.00000000519D42AD.00005EB5 Message-ID: X-Mailer: http://www.courier-mta.org/cone/ From: Sam Varshavchik To: pgsql-odbc@postgresql.org Subject: Cursor for a positioned update: =?UTF-8?Q?=22cursor?= does not =?UTF-8?B?ZXhpc3Qi?= error Date: Wed, 22 May 2013 18:11:57 -0400 Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=_monster.email-scan.com-14504-1369260717-0001"; micalg=pgp-sha1; protocol="application/pgp-signature" X-Pg-Spam-Score: -3.0 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org This is a MIME GnuPG-signed message. If you see this text, it means that your E-mail or Usenet software does not support MIME signed messages. The Internet standard for MIME PGP messages, RFC 2015, was published in 1996. To open this message correctly you will need to install E-mail or Usenet software that supports modern Internet standards. --=_monster.email-scan.com-14504-1369260717-0001 Content-Type: text/plain; format=flowed; delsp=yes; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 7bit I'm using postgresql-odbc-09.01.0200 with postgresl-9.2.4 According to the documention for SQLSetCursorName (http://msdn.microsoft.com/en-us/library/windows/desktop/ms711707%28v=vs.85%29.aspx) I don't really need to use it, and ODBC will use a default name. With unixODBC and a Postgresql connection handle, SQLGetInfo() shows SQL_CA1_POS_UPDATE capability for SQL_STATIC_CURSOR_ATTRIBUTES1, and SQL_KEYSET_CURSOR_ATTRIBUTES1. I tried using both a static and a keyset cursor, by setting SQL_ATTR_CURSOR_TYPE accordingly, on a new statement handle; then executing a "SELECT [..] FOR UPDATE", fetching multiple rows, using SQLSetPos to position on a given row, using SQLGetCursorName to retrieve the cursor's name, then attempting to execute an "UPDATE [..] WHERE CURRENT OF " on another statement handle. I'm basically following the script given here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms709389%28v=vs.85%29.aspx The original SELECT is a simple select on a table with a primary key, nothing fancy. The call to SQLGetCursorName returns a cursor name string like "SQL_CUR0x20c9480", but the subsequent UPDATE fails with a "cursor "sql_cur0x8de420" does not exist" error. If I try an explicit SQLSetCursorName before preparing the original SELECT, the subsequent SQLGetCursorName returns the cursor name I specify, but the UPDATE still fails with the error. When I strace the process, I don't see anything that suggests that a cursor gets really opened, I just see the plain original, unadorned, SELECT, being sent to the server: sendto(4, "Q\0\0\0BSELECT intkey, strval FROM temptbl ORDER BY intkey FOR UPDATE\0", 67, MSG_NOSIGNAL, NULL, 0) = 67 This is immediately followed by: sendto(4, "Q\0\0\0LUPDATE temptbl SET strval='2modified' WHERE CURRENT OF SQL_CUR0x1d2a210\0", 77, MSG_NOSIGNAL, NULL, 0) = 77 And the response to that is the error: recvfrom(4, "E\0\0\0_SERROR\0C34000\0Mcursor \"sql_cur0x1d2a210\" does not exist\0FexecCurrent.c\0L67\0RexecCurrentOf\0\0Z\0\0\0\5I", 4096, MSG_NOSIGNAL, NULL, NULL) = 102 With a MySQL connection instead, the same, simple test code appears to work as advertised. P.S. The positioned update example on MSDN references gives a "FOR UPDATE OF " clause, which seems to be an MS-ism, and Postgres doesn't like it even though the way the example is given would lead one to belive that it's DB-neutral SQL. Postgres accepts just a "FOR UPDATE" on a SELECT, except that something isn't working for me, and the cursor does not get created. --=_monster.email-scan.com-14504-1369260717-0001 Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) iEYEABECAAYFAlGdQq0ACgkQx9p3GYHlUOKP7ACePp+X7SdoCU71ND5QM2k+SCLk Ub8An0UjgrOPCzHFp5qQb6O1q4pz1DJq =+xfz -----END PGP SIGNATURE----- --=_monster.email-scan.com-14504-1369260717-0001--