Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cTF1K-0001La-BI for pgsql-odbc@arkaria.postgresql.org; Mon, 16 Jan 2017 21:40:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cTF1J-0001JR-UP for pgsql-odbc@arkaria.postgresql.org; Mon, 16 Jan 2017 21:40:53 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cRyxj-00024e-TG for pgsql-odbc@postgresql.org; Fri, 13 Jan 2017 10:20:00 +0000 Received: from m15-114.126.com ([220.181.15.114]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cRyxd-0003GE-J0 for pgsql-odbc@postgresql.org; Fri, 13 Jan 2017 10:19:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=ocQXL hfg5DoJV9Q/DJtyqn0qvtJk0VZ3wtkGT4i9eGg=; b=c2Gh/5wMTI2vnMNHyxs9t 9honwVycEwiv/yMGWxvbjP0CXpuUSMvmoACP47w8qz2euZjCvLpSNG3tgZuJ41H4 Cz4gHAB44itfmU65u1gG5TAYn1dUSO/RHm8EfN9fjS5KkZ2dC/zsFrkNHFfHo48W Za0SvtxT2SWTbb8baBEVCg= Received: from liujg (unknown [14.127.251.137]) by smtp7 (Coremail) with SMTP id DsmowAAn4lTCqXhY7sidEA--.24563S2; Fri, 13 Jan 2017 18:19:47 +0800 (CST) From: To: Subject: Row cannot be located for updating Date: Fri, 13 Jan 2017 18:19:45 +0800 Message-ID: <000301d26d86$9105fe20$b311fa60$@126.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0004_01D26DC9.9F315470" X-Mailer: Microsoft Outlook 14.0 Thread-Index: AdJtgsT3jyYvStE7TVudLjbU5liI3Q== Content-Language: zh-cn X-CM-TRANSID: DsmowAAn4lTCqXhY7sidEA--.24563S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7tFW3AF1xuF1fAr13uF1xZrb_yoW8Kw1xp3 9Y9wnIyFsFvF9rZw1xAw18W3yrZ3sxJ3yUtrZrta4UA390qas2kr40kF409F10krsY9rWr Xa1Yg3yrCa1DAaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j8HUgUUUUU= X-Originating-IP: [14.127.251.137] X-CM-SenderInfo: pkrzuxpdqjvqqrswhudrp/1tbijARemlWfoDgnkQAAso X-Pg-Spam-Score: -6.4 (------) 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 multipart message in MIME format. ------=_NextPart_000_0004_01D26DC9.9F315470 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Hi, It is not short of time to use postgresql for me, but recently got a = problem about record update as the title says. I have encountered the same error before and all been resolved, but this time it is a bit specific, the Internet couldn't help me to confirm the problem. I record the environment and the process of validation as follows. Hope to get help. =20 1.Enviroment: .PostgreSQL:9.3 .PostgreSQL ANSI 8.04.02.00=20 .client_encoding: GBK =20 =20 2.Test Table and Data: Create t_test_001 and insert 4 records for test. The script of create as follow: CREATE TABLE t_test_001 ( =20 id integer NOT NULL, name character varying(4), CONSTRAINT pk_test_001 PRIMARY KEY (id) =20 ); =20 Insert data. (1)insert into t_test_001(id,name) values(1,'=B4=F3'); --- without = trailling blank char_length=3D1 (2)insert into t_test_001(id,name) values(2,'=B4=F3 '); --- with 1 = trailling blank char_length=3D2 (3)insert into t_test_001(id,name) values(3,'=B4=F3 '); --- with 2 = trailling blank char_length=3D3 (4)insert into t_test_001(id,name) values(4,'=B4=F3 '); --- with 3 = trailling blank char_length=3D4 =20 notice the length of column id is 4. =20 3.Testing=20 Using ADO Recordset API such as Open,PutCollet,Update to update a = specific record. =20 The following code uses an ado wrapped class, but can be corresponding = to the original method. =20 string sql =3D "select name from t_test_001 where id=3D1"; ///< = id=3D1 locate the record want to update,replace 1 with the one want to update. string name =3D "a"; pRecordset =3D = pdbor->Query(sql.c_str(),adOpenStatic,adLockOptimistic);=20 if (!pRecordset->PutCollect("name",name.c_str())) return -1; if (!pRecordset->Update()) return -1; =20 change id in code above,execute for update every record in sequence. the results showed that it is ok for records with id=3D1,2,3,but the = record with id=3D4 raise error as follow: =CE=DE=B7=A8=CE=AA=B8=FC=D0=C2=B6=A8=CE=BB=D0=D0=A1=A3=D2=BB=D0=A9=D6=B5=BF= =C9=C4=DC=D2=D1=D4=DA=D7=EE=BA=F3=D2=BB=B4=CE=B6=C1=C8=A1=BA=F3=D2=D1=B8=FC= =B8=C4. (Row cannot be located for updating. some values may have been changed = since it was last read.) =20 i found serveral factors to bring this error:=20 .varchar column contains Chinese char .with trailling blank .length of data is width of the column=20 =20 how to explain and resolve it? =20 4.Additions .when i replace with PostgreSQL Unicode Driver,it's ok. .i would not set Update Criteria to adCriteriaKey to work around this,because it's not sure that all query always contains a primary key column. =20 Thank you, whereh ------=_NextPart_000_0004_01D26DC9.9F315470 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable

Hi,

It is not short of time to use postgresql for me, but = recently got a problem about record update as the title = says.

I = have encountered the same error before and all been resolved, but this = time it is a bit specific, the Internet couldn't help me to confirm the = problem.

I = record the environment and the process of validation as = follows.

Hope to get help.

 

1.Enviroment:

.PostgreSQL:9.3

.PostgreSQL ANSI 8.04.02.00 =

.client_encoding: GBK

 

 

2.Test Table and = Data:

Create t_test_001 and insert 4 records for = test.

The = script of create as follow:

CREATE TABLE = t_test_001

(

 

  id integer NOT NULL,

  name character = varying(4),

  CONSTRAINT pk_test_001 PRIMARY KEY = (id)

 

);

 

Insert data.

(1)insert into t_test_001(id,name) = values(1,'=B4=F3'); = --- without trailling blank   = char_length=3D1

(2)insert into t_test_001(id,name) values(2,'=B4=F3 '); = --- with 1 trailling blank   = char_length=3D2

(3)insert into t_test_001(id,name) values(3,'=B4=F3  '); --- with 2 trailling blank = char_length=3D3

(4)insert into t_test_001(id,name) values(4,'=B4=F3   '); --- with 3 trailling blank = char_length=3D4

 

notice the length of column id is = 4.

 

3.Testing

Using ADO Recordset API such as Open,PutCollet,Update to = update a specific record.

 

The following code uses an ado = wrapped class, but can be corresponding to the original = method.

 

   string sql =3D "select name from = t_test_001 where id=3D1"; ///< id=3D1 locate the record want to = update,replace 1 with the one want to update.

   string name =3D = "a";

   pRecordset =3D = pdbor->Query(sql.c_str(),adOpenStatic,adLockOptimistic); =

   if = (!pRecordset->PutCollect("name",name.c_str()))

      return = -1;

   if = (!pRecordset->Update())

         return = -1;

 

change id in code above,execute for update every record in = sequence.

the results showed that it is ok for records with = id=3D1,2,3,but the record with id=3D4 raise error as = follow:

=CE=DE=B7=A8=CE=AA=B8=FC=D0=C2=B6=A8=CE= =BB=D0=D0=A1=A3=D2=BB=D0=A9=D6=B5=BF=C9=C4=DC=D2=D1=D4=DA=D7=EE=BA=F3=D2=BB= =B4=CE=B6=C1=C8=A1=BA=F3=D2=D1=B8=FC=B8=C4.

(Row cannot be located for updating. some values may have = been changed since it was last read.)

 

i found serveral factors to bring = this error:

.varchar column contains Chinese = char

.with = trailling blank

.length of data is width of the column =

 

how to explain and resolve it?

 

4.Additions

.when i replace with PostgreSQL = Unicode Driver,it's ok.

.i would not set Update Criteria to adCriteriaKey to work = around this,because it's not sure that all query always contains a = primary key column.

 

Thank you,

whereh

------=_NextPart_000_0004_01D26DC9.9F315470--