Re: Problem writing function

From: Roman Neuhauser <neuhauser(at)sigpipe(dot)cz>
To: Christian Rengstl <Christian(dot)Rengstl(at)klinik(dot)uni-regensburg(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problem writing function
Date: 2006-08-06 12:42:33
Message-ID: 20060806124233.GA2849@dagan.sigpipe.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

# Christian(dot)Rengstl(at)klinik(dot)uni-regensburg(dot)de / 2006-08-06 11:47:43 +0200:
> 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,

should the tname be in_table?

> 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.

Is there a table called test1?

SELECT * FROM test1;
SELECT * FROM "test1";

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Francisco Reyes 2006-08-06 13:56:57 Re: Autovacuum help..
Previous Message Roman Neuhauser 2006-08-06 10:16:44 Re: