X-Original-To: pgsql-odbc@postgresql.org Received: from localhost (developer.postgresql.org [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id 61C91925304 for ; Wed, 28 May 2003 16:03:23 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193:10024]) (amavisd-new) with ESMTP id 25872-07 for ; Wed, 28 May 2003 16:03:22 -0400 (EDT) Received: from eciexchange.eldocomp.com (smtp.eldocomp.com [205.159.99.4]) by developer.postgresql.org (Postfix) with ESMTP id D86FE9251A5 for ; Wed, 28 May 2003 16:03:21 -0400 (EDT) Received: by eciexchange.eldocomp.com with XWall v3.26 ; Wed, 28 May 2003 13:03:20 -0700 From: Andrew Ayers To: "pgsql-odbc@postgresql.org" Subject: Re: TEXT datatype and ODBC? Date: Wed, 28 May 2003 13:04:32 -0700 X-Assembled-By: XWall v3.26 Message-ID: <3ED51650.6030301@eldocomp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/63 X-Sequence-Number: 2963 All, This is my first posting to this list - I posted a similar message to=20 the general list, and an individual by the name of Richard Huxton=20 suggested I try here. I appologize if this issue has already been=20 covered, however I didn't see anything in the archive that seemed to=20 address my problem. Basically, I have a legacy VB app that I am converting over to use=20 PostgreSQL. Prior to this, the VB app used DAO to update an Access 97=20 database. Certain tables on this database had fields which were of the=20 Memo datatype. I converted these on the PG side to TEXT fields. That is=20 when I noticed a problem, which seems to only be an issue with TEXT type=20 fields. When I go to do an "add" (via the AddNew method in DAO/VB), and I update=20 a field twice before committing the change (via the .update method in=20 DAO/VB), I get an error of "can't perform this operation" on the second=20 change of the field. My test code is as follows: Private Sub cmdTest_Click() ' Dim ws As Workspace Dim cn As Connection Dim db As Database Dim rs As Recordset ' Set ws =3D CreateWorkspace("WS", "", "", dbUseODBC) ' ws.DefaultCursorDriver =3D dbUseODBCCursor ' Set cn =3D ws.OpenConnection("", dbDriverComplete, False,=20 "ODBC;driver=3D{PostgreSQL};server=3Dmysvr;port=3D5433;database=3Dmydb;uid= =3D3Daayers;pwd=3D;ksqo=3D;") Set db =3D cn.Database ' Set rs =3D db.OpenRecordset("SELECT * FROM zzz_dummy", dbOpenDynaset,=20 dbExecDirect, dbOptimisticValue) ' Fails as "cant perform this operation" 'Set rs =3D db.OpenRecordset("SELECT * FROM zzz_dummy", dbOpenDynaset)= =20 ' Fails as "read only" 'Set rs =3D db.OpenRecordset("zzz_dummy", dbOpenDynaset) ' Fails as=20 "read only" ' With rs ' If .RecordCount > 0 Then ' .MoveLast .MoveFirst ' End If ' .AddNew ' ![a] =3D 1 ![a] =3D 2 ![b] =3D "test1" ![b] =3D "test2" ' .Update ' End With ' rs.Close db.Close cn.Close ws.Close ' End Sub The table can be recreated in PostgreSQL via: CREATE TABLE zzz_dummy(a int4, b text, PRIMARY KEY (a)); I am using DAO 3.51 methods and functions in this app. I have found that=20 if I do the same with any other PG datatype (in this case, the field=20 "a"), it works as expected - only on the TEXT datatype does it fail with=20 the error message. I am using the latest (7.3.200?) ODBC driver under=20 Windows XP Pro. Richard found that using a linked table from Access (he was using 2000 -=20 I am converting from 97), that the code would work OK. He wrote me saying: "Now with the code above "testA" is your style and "testB" is using a=20 linked table from Access 2000 to PG 7.3.2 - the linked table works, but=20 the "direct" connection doesn't. I think the problem is that the direct recordset isn't updatable. The=20 set of parameters "dbExecDirect" etc just means that this isn't noticed=20 until the "rs.Update". I'm guessing (and I must emphasise it's a guess) that it's because the connection doesn't know which fields are primary keys or somesuch -=20 looking at the ODBC log shows the linked table case just using a cursor=20 over the primary key (a)." --- Currently, the way I am getting around this issue (because in many areas=20 I need the large character fields for very long descriptions and such)=20 is by using big VARCHAR() fields (ie, VARCHAR(80000) or so). The problem=20 with these though is that doing any kind of select the accesses them in=20 any way (either as part of the select or of the WHERE clause), slows=20 down the select waaaaay down - a select that should take seconds takes=20 minutes (BTW - this is only via the ODBC connection - under psql the=20 same select is very quick). There should be other messages by me in the PostgreSQL General mailing=20 list archives regarding this error, but they basically say the same as=20 what I am posting here. Still, they may shed further light on the issue. Thank you all for any help you may be able to provide. I have a feeling=20 it is in the ODBC driver, but I don't know why. I suppose it could also=20 be my setup - but what this issue is, I don't really know. Sincerely, Andrew L. Ayers Phoenix, Arizona -- CONFIDENTIALITY NOTICE -- This message is intended for the sole use of the individual and entity to w= ho it is addressed, and may contain information that is privileged, confide= ntial and exempt from disclosure under applicable law. If you are not the i= ntended addressee, nor authorized to receive for the intended addressee, yo= u are hereby notified that you may not use, copy, disclose or distribute to= anyone the message or any information contained in the message. If you hav= e received this message in error, please immediately advise the sender by r= eply email, and delete the message. Thank you.