X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id BAE25D1B452 for ; Wed, 3 Dec 2003 10:13:23 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 95055-06 for ; Wed, 3 Dec 2003 06:12:54 -0400 (AST) Received: from itaqui.terra.com.br (itaqui.terra.com.br [200.176.3.19]) by svr1.postgresql.org (Postfix) with ESMTP id 3F0E8D1B445 for ; Wed, 3 Dec 2003 06:12:51 -0400 (AST) Received: from sucre.terra.com.br (sucre.terra.com.br [200.176.3.37]) by itaqui.terra.com.br (Postfix) with ESMTP id 6D855810330; Wed, 3 Dec 2003 08:12:47 -0200 (BRST) Received: from ttcristian (200-180-005-167.fnsce7006.dsl.brasiltelecom.net.br [200.180.5.167]) (authenticated user cristian_custodio) by sucre.terra.com.br (Postfix) with ESMTP id C02043C011; Wed, 3 Dec 2003 08:12:45 -0200 (BRST) Message-ID: <001601c3b98d$fb955120$b301a8c0@ttcristian> Reply-To: "Cristian Custodio" From: "Cristian Custodio" To: "Richard Combs" Cc: References: <005d01c3b50d$f1328c90$b301a8c0@ttcristian> <3FC6FD17.4020300@covad.net> <001d01c3b5ae$38a28da0$b301a8c0@ttcristian> <3FC8502D.7060805@covad.net> Subject: Re: Character invalid saving memo with UpdateSQL Date: Wed, 3 Dec 2003 08:09:55 -0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0013_01C3B974.D5C29570" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/5 X-Sequence-Number: 3543 This is a multi-part message in MIME format. ------=_NextPart_000_0013_01C3B974.D5C29570 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I will create a package and will send my TUpdateSQL component with this cha= nge to the groups list. Thanks Richard, Cristian ----- Original Message -----=20 From: Richard Combs=20 To: Cristian Custodio=20 Cc: pgsql-odbc@postgresql.org=20 Sent: Saturday, November 29, 2003 4:52 AM Subject: Re: [ODBC] Character invalid saving memo with UpdateSQL Since you mentioned update as the root of the problem, I retried my experiment. Same setup as before, however table1 was changed to the following bigtest=3D# \d table1 idnumber | integer | not null default nextval('public.ta= ble1_id number_seq'::text) c1 | character(40) | v2 | character varying(4000) | Sample Delphi code type TForm1 =3D class(TForm) Table1: TTable; DataSource1: TDataSource; DBGrid1: TDBGrid; Query1: TQuery; procedure DBGrid1DblClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.DBGrid1DblClick(Sender: TObject); begin { query is update table1 set v2 =3D :v2 where idnumber =3D :idnumber } // query1.Params[0].AsMemo :=3D 'mod '+table1.Fields[2].AsString; /= / this gives invalid characters query1.Params[0].AsString :=3D 'mod '+table1.Fields[2].AsString; /= / this gives only valid characters query1.Params[1].AsInteger :=3D table1.Fields[0].AsInteger; query1.ExecSQL; table1.Refresh; end; end. Table before any updates bigtest=3D# select * from table1; 1 | one | var one 2 | two | var two 3 | three | var three Table after updates using asMemo bigtest=3D# select * from table1; idnumber | c1 | v2 ----------+------------------------------------------+-------------------= ------- - 1 | one | var one 2 | two | mod var twoER 3 | three | mod mod mod var th= ree[i?=20 idnumber 2 errored after 1 modify=20 idnumber 3 errored after 3 modifies Table after updates using asString bigtest=3D# select * from table1; 1 | one | var one 3 | three | mod mod mod var th= ree 2 | two | mod mod mod mod mo= d mod mod var two As you said, the problem seems to be in using asMemo. Borland docs say Note: Some servers support string field types that are too long to fit in the record buffer. These fields are represented as memo fields, although they are not actually Blob fields. When working with such "pseudo-Blob" fields, use the AsString property instead. Also Memo fields are a form of binary large object (BLOB) field where the data= consists of simple text.=20 Use AsString to assign the BLOB field value to a string or to assign a st= ring value to the BLOB field. Typically, using AsString makes sense only if the BLOB contains text, suc= h as that in a memo field. The string data (Delphi) or AnsiString (C++) typ= e can, however, store binary data as well. Thus, even BLOB fields for nonte= xtual BLOB types such as ftGraphic or ftTypedBinary can use the AsString pr= operty. This would seem to be the case with varchar in PostgreSQL. Perhaps the best thing to do is use asString for all char and varchar columns unless you find an indication to the contrary. There are some mentions in the Borland newsgroups to having to use asMemo with Oracle. Check those out by searching the old archives,=20 you may still have to use asMemo to get your Oracle data. HTH Feel free to send me your code, and I will take a look at it. Cristian Custodio wrote: Sorry, I forget to say that the problem occur just in Upate, not in Ins= ert. And not in first time. You sometimes need update two or tree times until see the error. ------=_NextPart_000_0013_01C3B974.D5C29570 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
 
I will create a package and will send my T= UpdateSQL=20 component with this change to the groups list.
 
Thanks Richard,
 
Cristian
 
 
 
 
 
----- Original Message -----
Fro= m:=20 Richard Co= mbs=20
To: Cristian Custodio
Cc: pgsql-odbc@postgresql.org <= /DIV>
Sent: Saturday, November 29, 2003 = 4:52=20 AM
Subject: Re: [ODBC] Character inva= lid=20 saving memo with UpdateSQL

Since you mentioned update as the root of the problem, I= =20 retried my
experiment.  Same setup as before, however table1 was= =20 changed to the
following

bigtest=3D# \d table1
 idn= umber |=20 integer           =      =20 | not null default=20 nextval('public.table1_id
number_seq'::text)
 c1  &n= bsp;   =20 | character(40)         &nbs= p;=20 |
 v2       | character varying(400= 0)=20 |


Sample Delphi code

type
  TForm1 =3D=20 class(TForm)
     Table1: TTable;
  &= nbsp;=20  DataSource1: TDataSource;
    DBGrid1:=20 TDBGrid;
     Query1: TQuery;
   = ;=20  procedure DBGrid1DblClick(Sender: TObject);
 =20 private
     { Private declarations }
 =20 public
     { Public declarations }
 =20 end;

var
  Form1: TForm1;

implementation

{$R= =20 *.dfm}

procedure TForm1.DBGrid1DblClick(Sender:=20 TObject);
begin
    { query is
   = =20     update table1
       = set=20 v2 =3D :v2
        where idnumber =3D=20 :idnumber
    }
//   =20 query1.Params[0].AsMemo :=3D 'mod '+table1.Fields[2].AsString;  = ; =20 // this gives invalid characters
   =20 query1.Params[0].AsString :=3D 'mod=20 '+table1.Fields[2].AsString;    // this gives only valid= =20 characters
    query1.Params[1].AsInteger :=3D=20 table1.Fields[0].AsInteger;
   =20 query1.ExecSQL;
   =20 table1.Refresh;
end;

end.


Table before any=20 updates

bigtest=3D# select * from=20 table1;
        1 |=20 one           &nbs= p;            &= nbsp;           &nbs= p;=20 | var one
        2 |=20 two           &nbs= p;            &= nbsp;           &nbs= p;=20 | var two
        3 |=20 three           &n= bsp;            = ;           =20 | var three

Table after updates using asMemo

bigte= st=3D#=20 select * from table1;
 idnumber=20 |            =        =20 c1            = ;       =20 |           =20 v2

----------+------------------------------------------+---------= -----------------
-
       =20 1 |=20 one           &nbs= p;            &= nbsp;           &nbs= p;=20 | var one
        2 |=20 two           &nbs= p;            &= nbsp;           &nbs= p;=20 | mod var twoER
        3 |=20 three           &n= bsp;            = ;           =20 | mod mod mod var three[i?

idnumber 2 errored after 1 modify= =20
idnumber 3 errored after 3 modifies


Table after updates us= ing=20 asString

bigtest=3D# select * from=20 table1;
        1 |=20 one           &nbs= p;            &= nbsp;           &nbs= p;=20 | var one
        3 |=20 three           &n= bsp;            = ;           =20 | mod mod mod var three
        2 |= =20 two           &nbs= p;            &= nbsp;           &nbs= p;=20 | mod mod mod mod mod mod mod var two


As you said, the proble= m=20 seems to be in using asMemo.
Borland docs say
Note:  &nbs= p;=20 Some servers support string field types
that are too long to fit in th= e=20 record buffer.
These fields are represented as memo fields,
althoug= h=20 they are not actually Blob fields.
When working with such =93pseudo-Bl= ob=94=20 fields,
use the AsString property instead.

Also

Memo fie= lds=20 are a form of binary large object (BLOB) field where the data consists of= =20 simple text.
Use AsString to assign the BLOB field value to a string = or to=20 assign a string value to the BLOB field.
Typically, using AsString mak= es=20 sense only if the BLOB contains text, such as that in a memo field. The s= tring=20 data (Delphi) or AnsiString (C++) type can, however, store binary data as= =20 well. Thus, even BLOB fields for nontextual BLOB types such as ftGraphic = or=20 ftTypedBinary can use the AsString property.


This would seem t= o be=20 the case with varchar in PostgreSQL.  Perhaps
the best thing to d= o is=20 use asString for all char and varchar columns
unless you find an indic= ation=20 to the contrary.

There are some mentions in the Borland newsgroups= to=20 having to use
asMemo with Oracle.  Check those out by searching t= he=20 old archives,
you may still have to use asMemo to get your Oracle=20 data.


HTH

Feel free to send me your code, and I will ta= ke a=20 look at it.


Cristian Custodio wrote:
 
Sorry, I forget to say that the proble= m occur=20 just in Upate, not in Insert.
And not in first time. You sometimes n= eed=20 update two or tree times
until see the=20 error.

------=_NextPart_000_0013_01C3B974.D5C29570--