Re: computed values in plpgsql

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: computed values in plpgsql
Дата
Msg-id 162867790909290842s1a0d8781vb1bd0f4aa7fb7c1e@mail.gmail.com
обсуждение исходный текст
Ответ на Re: computed values in plpgsql  (Reid Thompson <reid.thompson@ateb.com>)
Ответы Re: computed values in plpgsql  (Sam Mason <sam@samason.me.uk>)
Список pgsql-general
2009/9/29 Reid Thompson <reid.thompson@ateb.com>:
> On Tue, 2009-09-29 at 07:54 -0400, Merlin Moncure wrote:
>
>> you are missing some quotes in there.  also, don't use 'values', use
>> select.  see my example above:
>> execute 'insert into foo_something select (''' || new::text || '''::foo).*';
>>
>> the actual query should look like:
>> insert into payments(payment_name, payment_type, when_done, amount)
>>   select ('(7,FRED,WIDGET,"2009-01-15 14:20:00",14.500)'::payments).*;
>>
>> merlin
>
> Merlin,
> thank you.  That appears to work except for one case. If one of the
> string literals in the insert happens to have an escaped quote (e.g.
> 'Joe''s Crabshack') the insert falls over due to quoting.
>
> insert into inquiries(who, when_done, question ) values('FRED',TIMESTAMP '2009-01-16 09:14:00', 'Where''s my money');
>
> LINE 1: ...901 select ('(1,FRED,"2009-01-16 09:14:00","Where's my money...
>                                                             ^
> QUERY:  insert into inquiries_200901 select ('(1,FRED,"2009-01-16 09:14:00","Where's my money")'::inquiries).*

you cannot use double quotes. It's not php.

regards
Pavel Stehule


>
> Does anyone know...
>  if 8.4 would have the same issue?
>  is there a non-trivial solution to this that could be implemented in the plpgsql function
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

В списке pgsql-general по дате отправления:

Предыдущее
От: Devrim GÜNDÜZ
Дата:
Сообщение: Re: could not reattach to shared memory
Следующее
От: Alan Hodgson
Дата:
Сообщение: Re: bulk inserts