From: | "Vyacheslav Kalinin" <vka(at)mgcp(dot)com> |
---|---|
To: | "A B" <gentosaker(at)gmail(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: need help with drop table command |
Date: | 2008-05-30 20:57:48 |
Message-ID: | 9b1af80e0805301357t2b711a6ew4076b5cacbc9993b@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On 5/30/08, A B <gentosaker(at)gmail(dot)com> wrote:
>
> 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;
>
SELECT count(*) FROM pg_tables WHERE tableowner='bduser'; <---- This one
has no target
Either do `SELECT count(*) INTO somevar ...` or `PERFORM count(*) ...`
From | Date | Subject | |
---|---|---|---|
Next Message | Netzach | 2008-06-01 09:27:12 | Running .psqlrc from a custom location |
Previous Message | Mike Ellsworth | 2008-05-30 10:32:38 | Re: Dreamweaver 8 and PostgreSQL 'integration' with PHP??? |