Re: Minor systax error but not able to resolve it...

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Minor systax error but not able to resolve it...
Дата
Msg-id 4B83C223.30909@archonet.com
обсуждение исходный текст
Ответ на Minor systax error but not able to resolve it...  (dipti shah <shahdipti1980@gmail.com>)
Ответы Re: Minor systax error but not able to resolve it...  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On 23/02/10 11:25, dipti shah wrote:
> Hi, could anyone please help me to sort out below error. I have spent lot of
> time but couldn't resolved it.

 > ERROR:  error from Perl function "test_create": syntax error at or near
 > "CREATE" at line 3.


> spi_exec_query("CREATE OR REPLACE FUNCTION my_tmp_func() RETURNS void AS
> $cmd LANGUAGE sql;");

You're interpolating $cmd here but not quoting it, so you end up with:
... RETURNS void AS CREATE TABLE test-table...
whereas you want:
... RETURNS void AS 'CREATE TABLE test-table...'...

Probably best to use dollar-quoting: $TMP$ or similar, but don't forget
to escapt the $ or perl will think it's a variable.

--
   Richard Huxton
   Archonet Ltd

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

Предыдущее
От: Thom Brown
Дата:
Сообщение: Re: Subqueries or Joins? Problems with multiple table query
Следующее
От: "A. Kretschmer"
Дата:
Сообщение: Re: Subqueries or Joins? Problems with multiple table query