Re: Select Command in Procedures

From: Christian Ullrich <chris(at)chrullrich(dot)net>
To: pgsql-admin(at)postgresql(dot)org
Cc: Adarsh Sharma <adarsh(dot)sharma(at)orkash(dot)com>
Subject: Re: Select Command in Procedures
Date: 2011-02-03 09:34:14
Message-ID: 4D4A7696.8030802@chrullrich.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

* Adarsh Sharma wrote:

> I am able to execute command successfully through CLI or pgAdmin .
>
> *create table user_news_new as select
> record_id,field_name,field_value,news_date from user_news where
> field_name in ('SOI','RelLoc','Description','Heading','news_date') and
> field_value != '' ; *
>
> But I don't know when I put this command in a procedure, it shows error :
>
> CREATE FUNCTION user10() RETURNS void AS'
> DECLARE
> BEGIN
> create table user_news_new as select
> record_id,field_name,field_value,news_date from user_news where
> field_name in ('SOI','RelLoc','Description','Heading','news_date') and
> field_value != '' ;
> END;
> ' LANGUAGE 'plpgsql';

You are using single quotation marks around your function body already.
Use dollar quoting instead.

--
Christian

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Gnanakumar 2011-02-03 12:00:08 Is there a batch/bulk UPDATE syntax available?
Previous Message Adarsh Sharma 2011-02-03 08:57:57 Select Command in Procedures