Problem writing function - Mailing list pgsql-general

From Christian Rengstl
Subject Problem writing function
Date
Msg-id 44D5D6FB02000080000413DC@rrzgw1.uni-regensburg.de
Whole thread Raw
Responses Re: Problem writing function  (Roman Neuhauser <neuhauser@sigpipe.cz>)
List pgsql-general
Hi list,

the following function is created properly:
CREATE OR REPLACE FUNCTION insert_into_table_overview(text, chr integer)
RETURNS void AS '
DECLARE
        in_table                ALIAS FOR $1;
        p RECORD;
BEGIN
    RAISE NOTICE ''in_table = %'', in_table;
    FOR p IN EXECUTE ''select distinct pid from '' ||
quote_ident(in_table) LOOP
        EXECUTE ''insert into table_overview(table_name, chr,
start_no, end_no, pid)
        select '' || quote_ident(tname) || '', chr,
min(entry_no), max(entry_no), p from '' || quote_ident(in_table);
    END LOOP;
END;
' LANGUAGE plpgsql;

But when i execute it with select
insert_into_table_overview('test1'::text, 1); i only get the following
output:
NOTICE:  in_table = test1

ERROR:  relation "test1" does not exist
CONTEXT:  SQL statement "select distinct pid from "test1""
PL/pgSQL function "insert_into_table_overview" line 6 at for over
execute statement

I am sure that there is something wrong with the quotes, but i just
can't find out what.

Chris




pgsql-general by date:

Previous
From: "Marco Bizzarri"
Date:
Subject: Re: Consulta
Next
From: Roman Neuhauser
Date:
Subject: Re: Problem writing function