pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedSelect Command in Procedures
2+ messages / 2 participants
[nested] [flat]
* Select Command in Procedures
@ 2011-02-03 08:57 Adarsh Sharma <adarsh.sharma@orkash.com>
0 siblings, 1 reply; 2+ messages in thread
From: Adarsh Sharma @ 2011-02-03 08:57 UTC (permalink / raw)
To: pgsql-admin
Dear all,
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';
Error :
globe=# CREATE FUNCTION user10() RETURNS void AS'
globe'# DECLARE
globe'# BEGIN
globe'# 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 != '' ;
globe'# END;
globe'# ' LANGUAGE 'plpgsql';
ERROR: syntax error at or near "SOI"
LINE 4: ...ue,news_date from user_news where field_name in ('SOI','RelL...
^
Please help as I stuck with this issue.
Thanks & Regards
Adarsh Sharma
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Select Command in Procedures
@ 2011-02-03 09:34 Christian Ullrich <chris@chrullrich.net>
parent: Adarsh Sharma <adarsh.sharma@orkash.com>
0 siblings, 0 replies; 2+ messages in thread
From: Christian Ullrich @ 2011-02-03 09:34 UTC (permalink / raw)
To: pgsql-admin; +Cc: Adarsh Sharma <adarsh.sharma@orkash.com>
* 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2011-02-03 09:34 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-02-03 08:57 Select Command in Procedures Adarsh Sharma <adarsh.sharma@orkash.com>
2011-02-03 09:34 ` Christian Ullrich <chris@chrullrich.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox