Received: from bologna.nettuno.it (bologna.nettuno.it [193.43.2.1]) by hub.org (8.9.3/8.9.1) with ESMTP id IAA57540 for ; Wed, 21 Apr 1999 08:48:51 -0400 (EDT) (envelope-from jose@sferacarta.com) Received: from proxy.sferacarta.com (mail@sfcabop1.nettuno.it [193.207.10.213]) by bologna.nettuno.it (8.8.6/8.8.6/NETTuno 3.1) with ESMTP id OAA22818; Wed, 21 Apr 1999 14:48:25 +0200 (MDT) Received: from rosso.sferacarta.com (sferacarta.com) [10.20.30.5] by proxy.sferacarta.com with esmtp (Exim 2.05 #1 (Debian)) id 10ZyAZ-0001l0-00; Wed, 21 Apr 1999 14:40:07 +0000 Message-ID: <371DC711.221743A7@sferacarta.com> Date: Wed, 21 Apr 1999 14:39:45 +0200 From: =?iso-8859-1?Q?Jos=E9?= Soares X-Mailer: Mozilla 4.5 [it] (Win95; I) X-Accept-Language: it MIME-Version: 1.0 To: chairudin@prima.net.id CC: pgsql-sql@postgresql.org Subject: Re: [SQL] Update on 6.5 References: <199904152011.QAA26538@fnur.3skel.com> <37175B7B.F6DD87E2@prima.net.id> <37173AE2.4FB7C0D5@sferacarta.com> <371D8E0F.C2097B01@prima.net.id> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Try this function: create function a(int,text) returns text as 'begin update ibs_br_all_total_units set first_name = $2 where pin = $1; RETURN $2; end; ' language 'plpgsql'; create table ibs_subscriber( pin int, first_name text); insert into ibs_subscriber values(1,'pippo'); insert into ibs_subscriber values(3,'pluto'); create table ibs_br_all_total_units( pin int, first_name text); insert into ibs_br_all_total_units values(1,'text'); insert into ibs_br_all_total_units values(2,'text'); insert into ibs_br_all_total_units values(3,'text'); select * from ibs_subscriber ; pin|first_name ---+---------- 1|pippo 3|pluto (2 rows) select * from ibs_br_all_total_units ; pin|first_name ---+---------- 1|text 2|text 3|text (3 rows) select a(pin,first_name) from ibs_subscriber ; a ----- pippo pluto (2 rows) select * from ibs_br_all_total_units ; pin|first_name ---+---------- 2|text 1|pippo 3|pluto (3 rows) José Chairudin Sentosa ha scritto: > José Soares wrote: > > > Chairudin Sentosa ha scritto: > > > > > Hi, > > > > > > I am using postgresql 6.5 snapshot. > > > I can not update. > > > Could anyone tell me what's wrong, please? > > > > > > update ibs_br_all_total_units tr set first_name= > > > (select first_name from ibs_subscriber tn > > > where tr.pin = tn.pin > > > ); > > > > > > "/tmp/psql.60000.13342" 4 lines, 117 characters > > > ERROR: parser: syntax error at or near "tr" > > > > > > > AFAIK PostgreSQL doesn't allow subselects on UPDATE. > > > > José > > Hi Jose, > > How should I do it in PostgreSQL? > > Thanks > > Regards, > Chai