Re: [INTERFACES] sql question
От | Tom Lane |
---|---|
Тема | Re: [INTERFACES] sql question |
Дата | |
Msg-id | 25795.944635216@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | sql question (Joseph Shraibman <jks@p1.selectacast.net>) |
Список | 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
В списке pgsql-interfaces по дате отправления: