pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: José Soares <jose@sferacarta.com>
To: chairudin@prima.net.id
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Update on 6.5
Date: Wed, 21 Apr 1999 14:39:45 +0200
Message-ID: <371DC711.221743A7@sferacarta.com> (raw)
References: <199904152011.QAA26538@fnur.3skel.com>
	<37175B7B.F6DD87E2@prima.net.id>
	<37173AE2.4FB7C0D5@sferacarta.com>
	<371D8E0F.C2097B01@prima.net.id>

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




view thread (4+ messages)

Message-ID: <371DC711.221743A7@sferacarta.com>
Permalink:  ../371DC711.221743A7@sferacarta.com/
Also on:    postgresql.org/message-id/371DC711.221743A7@sferacarta.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: jose@sferacarta.com, chairudin@prima.net.id
  Subject: Re: [SQL] Update on 6.5
  In-Reply-To: <371DC711.221743A7@sferacarta.com>
  References: <199904152011.QAA26538@fnur.3skel.com> <37175B7B.F6DD87E2@prima.net.id> <37173AE2.4FB7C0D5@sferacarta.com> <371D8E0F.C2097B01@prima.net.id> <371DC711.221743A7@sferacarta.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox