The following function takes a table name as a parameter and drops
the table and returns true if there are zero rows (otherwise, it
returns false):
CREATE OR REPLACE FUNCTION dropzero( varchar ) RETURNS bool AS '
DECLARE
zerotable ALIAS FOR $1;
zerocurs refcursor;
rowc
PostgreSQL 7.4 ...
I'm trying to find a way to drop a table via SQL if it contains 0 rows. Here
was my thought:
CREATE OR REPLACE FUNCTION dropif(text, bool)
RETURNS bool AS
'DECLARE
tblname ALIAS FOR $1;
condition ALIAS FOR $2;
BEGIN
IF (condition) THEN
EXECUTE(\'DROP TABLE "\' || tb