pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedsql question
5+ messages / 3 participants
[nested] [flat]
* sql question
@ 1999-12-08 02:14 Joseph Shraibman <jks@p1.selectacast.net>
0 siblings, 2 replies; 5+ messages in thread
From: Joseph Shraibman @ 1999-12-08 02:14 UTC (permalink / raw)
To: pgsql-interfaces
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') ;
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [INTERFACES] sql question
@ 1999-12-08 06:40 Tom Lane <tgl@sss.pgh.pa.us>
parent: Joseph Shraibman <jks@p1.selectacast.net>
1 sibling, 0 replies; 5+ messages in thread
From: Tom Lane @ 1999-12-08 06:40 UTC (permalink / raw)
To: Joseph Shraibman <jks@p1.selectacast.net>; +Cc: pgsql-interfaces
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [INTERFACES] sql question
@ 1999-12-08 07:45 Michael Meskes <meskes@postgreSQL.org>
parent: Joseph Shraibman <jks@p1.selectacast.net>
1 sibling, 1 reply; 5+ messages in thread
From: Michael Meskes @ 1999-12-08 07:45 UTC (permalink / raw)
To: Joseph Shraibman <jks@p1.selectacast.net>; +Cc: pgsql-interfaces
On Tue, Dec 07, 1999 at 09:14:37PM -0500, Joseph Shraibman wrote:
> INSERT INTO application (key, creator, name) values ( 1 ,(select userkey
> from
> user where username = 'b' ), 'newapplication') ;
INSERT INTO application (key, creator, name) SELECT 1, userkey,
'newapplication' from user where username = 'b';
Michael
--
Michael Meskes | Go SF 49ers!
Th.-Heuss-Str. 61, D-41812 Erkelenz | Go Rhein Fire!
Tel.: (+49) 2431/72651 | Use Debian GNU/Linux!
Email: Michael@Fam-Meskes.De | Use PostgreSQL!
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [INTERFACES] sql question
@ 1999-12-08 19:36 Joseph Shraibman <jks@p1.selectacast.net>
parent: Michael Meskes <meskes@postgreSQL.org>
0 siblings, 1 reply; 5+ messages in thread
From: Joseph Shraibman @ 1999-12-08 19:36 UTC (permalink / raw)
To: Michael Meskes <meskes@postgreSQL.org>; +Cc: Joseph Shraibman <jks@p1.selectacast.net>; pgsql-interfaces
Michael Meskes wrote:
> On Tue, Dec 07, 1999 at 09:14:37PM -0500, Joseph Shraibman wrote:
> > INSERT INTO application (key, creator, name) values ( 1 ,(select userkey
> > from
> > user where username = 'b' ), 'newapplication') ;
>
> INSERT INTO application (key, creator, name) SELECT 1, userkey,
> 'newapplication' from user where username = 'b';
>
owl=> INSERT INTO application (key, creator, name) values (select 1,userkey,
'newapplication' from user where username = 'b' ) ;
ERROR: parser: parse error at or near "select"
owl=> INSERT INTO application (key, creator, name) SELECT 1, userkey,
owl-> 'newapplication' from user where username = 'b';
ERROR: parser: parse error at or near "user"
owl=>
Any other ideas?
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [INTERFACES] sql question
@ 1999-12-08 20:28 Joseph Shraibman <jks@p1.selectacast.net>
parent: Joseph Shraibman <jks@p1.selectacast.net>
0 siblings, 0 replies; 5+ messages in thread
From: Joseph Shraibman @ 1999-12-08 20:28 UTC (permalink / raw)
To: Joseph Shraibman <jks@p1.selectacast.net>; +Cc: Michael Meskes <meskes@postgreSQL.org>; pgsql-interfaces
Joseph Shraibman wrote:
> Michael Meskes wrote:
>
>
OK I actually figured part of the problem was that postgres doesn't like the
table name 'user' so I had changed the name to 'usertable'.
Thanks all.
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~1999-12-08 20:28 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-12-08 02:14 sql question Joseph Shraibman <jks@p1.selectacast.net>
1999-12-08 06:40 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-12-08 07:45 ` Michael Meskes <meskes@postgreSQL.org>
1999-12-08 19:36 ` Joseph Shraibman <jks@p1.selectacast.net>
1999-12-08 20:28 ` Joseph Shraibman <jks@p1.selectacast.net>
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