From: Tom Lane <tgl@sss.pgh.pa.us>
To: Joseph Shraibman <jks@p1.selectacast.net>
Cc: pgsql-interfaces@postgreSQL.org
Subject: Re: [INTERFACES] sql question
Date: Wed, 08 Dec 1999 01:40:16 -0500
Message-ID: <25795.944635216@sss.pgh.pa.us> (raw)
In-Reply-To: <384DBF0D.DF9C29AB@selectacast.net>
Joseph Shraibman <jks@p1.selectacast.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
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 using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: tgl@sss.pgh.pa.us, jks@p1.selectacast.net
Subject: Re: [INTERFACES] sql question
In-Reply-To: <25795.944635216@sss.pgh.pa.us>
* 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