<div dir="ltr">thank you Sergio.<br /><br />I decided to use <br /><br />EXECUTE v_stmt into v_total_pop;<br /><br
/><br/><div class="gmail_quote">On Thu, Sep 4, 2008 at 2:00 PM, Ivan Sergio Borgonovo <span dir="ltr"><<a
href="mailto:mail@webthatworks.it">mail@webthatworks.it</a>></span>wrote:<br /><blockquote class="gmail_quote"
style="border-left:1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">On
Thu,4 Sep 2008 13:41:16 -0700<br /> "Ruben Gouveia" <<a
href="mailto:rubes7202@gmail.com">rubes7202@gmail.com</a>>wrote:<br /><br /> > I created a simple function that i
wantto use another function<br /> > (in the same schema) that will be used to create a sql statement.<br /> > I
getthe following error when i try this:<br /> ><br /> > *ERROR: syntax error at or near "EXEC" at character 1<br
/>> QUERY: EXEC SQL EXECUTE $1 INTO $2<br /> > CONTEXT: SQL statement in PL/PgSQL function "fcn_population"
near<br/> > line 10<br /><br /></div><div class="Ih2E3d">> EXEC SQL EXECUTE v_stmt INTO v_total_pop;<br /><br
/></div>Couldit be you're mixing MS SQL (Oracle?) syntax with pgplsql syntax<br /><div class="Ih2E3d"><br /> EXECUTE
v_stmtINTO v_total_pop;<br /><br /></div><a
href="http://www.postgresql.org/docs/8.3/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN"
target="_blank">http://www.postgresql.org/docs/8.3/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN</a><br
/><br/> --<br /> Ivan Sergio Borgonovo<br /><a href="http://www.webthatworks.it"
target="_blank">http://www.webthatworks.it</a><br/><font color="#888888"><br /><br /> --<br /> Sent via pgsql-sql
mailinglist (<a href="mailto:pgsql-sql@postgresql.org">pgsql-sql@postgresql.org</a>)<br /> To make changes to your
subscription:<br/><a href="http://www.postgresql.org/mailpref/pgsql-sql"
target="_blank">http://www.postgresql.org/mailpref/pgsql-sql</a><br/></font></blockquote></div><br /></div>