I'm having some dramas getting a basic dynamic function to go, similar to
the one from Phillip Allen's posting from the other day...I'm attempting to
get the function to return the count(*) for a table name supplied to it:
CREATE FUNCTION test_func(text) RETURNS text AS '
qry:= ''SELECT COUNT(*) AS numrows FROM '' || $1 || '';'';
FOR rec IN EXECUTE qry LOOP
' LANGUAGE 'plpgsql';
The double quotes in the assignment to the qry variable are two single
quotes, if this is unclear. I get the following:
test=# select test_func('test_table');
NOTICE: plpgsql: ERROR during compile of test_func near line 7
ERROR: parse error at or near "EXECUTE"
After searching all the techdocs and the excellent Practical Postgresql and
other resources, I am still none the wiser...can anyone lend me a few brain
cells? I'm running 7.0.3.
pgsql-novice by date
|Next:||From: Tom Lane||Date: 2001-08-21 14:38:06|
|Subject: Re: For In Execute |
|Previous:||From: D. Duccini||Date: 2001-08-21 02:52:10|
|Subject: Re: installing on sunos 5.7 |