X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 92ED030F353 for ; Wed, 18 Jun 2003 08:59:39 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 93133-01 for ; Wed, 18 Jun 2003 05:59:29 -0300 (ADT) Received: from ns.naus.home (M1241P006.adsl.highway.telekom.at [80.121.27.6]) by svr1.postgresql.org (Postfix) with ESMTP id C0D6230F33D for ; Wed, 18 Jun 2003 05:59:27 -0300 (ADT) Received: from aon.at (erwin@[192.168.2.102]) by ns.naus.home (8.11.2/8.11.2) with ESMTP id h5I8xQM11616 for ; Wed, 18 Jun 2003 10:59:26 +0200 Message-ID: <3EF029EE.9040002@aon.at> Date: Wed, 18 Jun 2003 10:59:26 +0200 From: Erwin Ambrosch Reply-To: erwin.ambrosch@aon.at Organization: netzwerkanwendungen & services User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3.1) Gecko/20030425 X-Accept-Language: de-at, en-us, en MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: pgsql function doesn't work Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200306/233 X-Sequence-Number: 9224 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