Re: [INTERFACES] sql question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joseph Shraibman <jks(at)p1(dot)selectacast(dot)net>
Cc: pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] sql question
Date: 1999-12-08 06:40:16
Message-ID: 25795.944635216@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Joseph Shraibman <jks(at)p1(dot)selectacast(dot)net> writes:
> Is there any way to get something like this into valid sql? Postgres
> doesn't like this:

> INSERT INTO application (key, creator, name) values ( 1 ,(select userkey
> from user where username = 'b' ), 'newapplication') ;

FWIW, this works in current sources and will be in the next release
(6.6 or 7.0 or whatever...). 6.5 doesn't support sub-selects in
target lists, which is what you have here. You could work around it
with something like

INSERT INTO application SELECT 1, userkey, 'newapplication' FROM
user WHERE username = 'b';

although this doesn't mean quite the same thing (if there are multiple
user rows with username = 'b', the former raises an error while the
latter inserts multiple rows into application).

BTW: I dunno what version you are running, but "user" has been a
reserved word at least since 6.5. Might be good to rename your table
before upgrading.

regards, tom lane

Browse pgsql-interfaces by date

  From Date Subject
Next Message Tom Lane 1999-12-08 06:53:30 Re: [INTERFACES] locking on database updates
Previous Message Douglas Thomson 1999-12-08 04:34:33 Re: [INTERFACES] locking on database updates