<div dir="ltr">I created a simple function that i want to use another function (in the same schema) that will be used
tocreate a sql statement. I get the following error when i try this:<br /><br /><font size="2"><i style="color:
rgb(204,0, 0);">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 line 10<br /><br />********** Error **********<br
/><br/>ERROR: syntax error at or near "EXEC"<br /> SQL state: 42601<br />Context: SQL statement in PL/PgSQL function
"fcn_population"near line 10</i></font><br /><br />Here is my function:<br /><br />CREATE OR REPLACE FUNCTION
fcn_population(p_datedate, p_where varchar)<br /> RETURNS numeric AS $$<br /><br />DECLARE<br /> v_total_pop numeric
:=0;<br /> v_stmt varchar(1024);<br /> v_where varchar(256) := 'where m.date_created < '||p_date||' '||+
integer'1'||' ';<br /> <br /><br />BEGIN<br /> v_stmt := fcn_gen_statement(p_type,
v_where,0);<br /> EXEC SQL EXECUTE v_stmt INTO v_total_pop;<br /> return v_total_pop;<br />END;<br />$$ LANGUAGE
plpgsql;<br/><br /><br /></div>