pgsql function doesn't work

From: Erwin Ambrosch <erwin(dot)ambrosch(at)aon(dot)at>
To: pgsql-admin(at)postgresql(dot)org
Subject: pgsql function doesn't work
Date: 2003-06-18 08:59:26
Message-ID: 3EF029EE.9040002@aon.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi,

the function bellow is created successfully, but executing it forces the
following error message:

WARNING: Error occurred while executing PL/pgSQL function
drop_table_if_exists
WARNING: line 5 at select into variables
ERROR: parser: parse error at or near "$1" at character 34

CREATE OR REPLACE FUNCTION drop_table_if_exists(TEXT) RETURNS BOOLEAN AS '
DECLARE
rec RECORD;
BEGIN

SELECT INTO rec off_mitarbeiter_id FROM $1;

IF FOUND THEN
EXECUTE ''DROP TABLE'' || '' '' || $1;
RETURN true;
END IF;

RETURN false;

END;'
LANGUAGE 'plpgsql';
select drop_table_if_exists('off_jahres_abr_2003');

If I hardcode the table name istead of using $1, everything works fine.

Please help.

Thanx Erwin

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Peter Eisentraut 2003-06-18 12:14:58 Re: configure readline error
Previous Message Anagha Joshi 2003-06-18 08:00:08 Create Rule/trigger