Обсуждение: cannot use result of (insert .. returning)

Поиск
Список
Период
Сортировка

cannot use result of (insert .. returning)

От
"dvs"
Дата:
Hello,

I need to use query like:
    select (insert into test (a) values (x) returning b),c from anytable
where condition
but it say
    ERROR: syntax error at or near "into"

Is this a bug?

Function does not work too:
  create function addt(..) returning .. as 'insert ... returning ..'
language 'sql'
ERROR:...
DETAIL: Function's final statement must be a SELECT.

BUT:
   create function addt(..) returning .. as
'insert...(nextval('..')...);select currval('..')' language 'sql'
work in
    select addt(x),c from anytable where condition

but this function is analog of "insert...returning" in any case
Why analog work "better" then original?
What is my mistake? (I dont want use functions here!)

dvs


Re: cannot use result of (insert .. returning)

От
Tino Wildenhain
Дата:
dvs wrote:
> Hello,
>
> I need to use query like:
>    ,c from anytable
> where condition
> but it say
>    ERROR: syntax error at or near "into"

did you try with:

select (insert into test (a) values (x) returning b) query_a JOIN c ON ... ?

Tino.

Вложения

Re: cannot use result of (insert .. returning)

От
"dvs"
Дата:
>> I need to use query like:
>>    ,c from anytable where condition
>> but it say
>>    ERROR: syntax error at or near "into"
>
> did you try with:
> select (insert into test (a) values (x) returning b) query_a JOIN c ON ...
> ?

you about
   select * from (insert into test (a) values (x) returning b) z
?
it get the same error...