Howdy:
Running Postgres 7.1.3 on RedHat Linux.
Can someone give me an example of
using the EXECUTE command while
in a function? For example, I'd like to
create a table using EXECUTE, but I'm
not sure about it's use (or how to use
create in a function).
My goal is to do something like this:
[snip code]
drop function t_member_cnt(int);
create function t_member_cnt(int)
returns integer
as '
declare nCnt int4;
begin
select count (*) from test_table into nCnt;
if nCnt < 1500000 then
return nCnt;
else
execute drop test_table;
execute select * into test_table from standby_table
where user_id=''3924'';
end if;
return nCnt;
end; '
language 'plpgsql';
-- change to user and execute the function
--
\c database joeuser
select t_member_cnt(0);
-- do the permissions part
--
grant select on test_table to public
drop index test_i;
create index test_i;
[/snip code]
Perhaps I've missed it, but I haven't see much in the
way of 'real world examples' using execute.
Suggestions welcomed!
Thanks!
-X