need help with drop table command

From: "A B" <gentosaker(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: need help with drop table command
Date: 2008-05-30 08:54:57
Message-ID: dbbf25900805300154o68105ff6p645288942388a17c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I'm writing a function to drop tables until there is no table left,
but I get an error

ERROR: query has no destination for result data, It seems to be on
the line with the EXECUTE command.
Can someone help me understand this error?

CREATE OR REPLACE FUNCTION droptables() RETURNS void AS $$
DECLARE
post RECORD;
BEGIN
LOOP
FOR post IN SELECT tablename FROM pg_tables WHERE tableowner='bduser' LOOP
BEGIN
EXECUTE 'DROP TABLE '||post.tablename;
EXCEPTION WHEN OTHERS THEN
END;
END LOOP;
SELECT count(*) FROM pg_tables WHERE tableowner='bduser';
IF NOT FOUND THEN
EXIT; --avbryt om vi inte hittar fler
END IF;
END LOOP;
END;
$$ LANGUAGE plpgsql;

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message A B 2008-05-30 09:30:51 How does quotes work with dynamic queries?
Previous Message Greg Cocks 2008-05-29 22:27:57 Dreamweaver 8 and PostgreSQL 'integration' with PHP???