Correctly quoting inside plpgql functions

From: alberto bolchini <ibolks(at)tiscali(dot)it>
To: pgsql-novice(at)postgresql(dot)org
Subject: Correctly quoting inside plpgql functions
Date: 2002-04-20 06:59:47
Message-ID: 3CAC05F1000195AD@mail.tiscalinet.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi all.
I'm trying to create a function which should return a cursor (to be used
from a jdbc connection) and I'm experiencing problems in quoting (I believe)
correctly inside the function:

<code>
jsg_2=# CREATE FUNCTION myfun(char(2)) RETURNS refcursor AS
jsg_2-# ' DECLARE
jsg_2'# l_lang alias for $1;
jsg_2'# l_cursor refcursor;
jsg_2'# BEGIN
jsg_2'# OPEN l_cursor FOR EXECUTE
jsg_2'# ''SELECT * FROM t INNER JOIN i18n ON t.id=i18n.id AND i18n.language_id=''
|| quote_ident(l_lang) || '' ORDER BY description'';
jsg_2'# RETURN l_cursor;
jsg_2'# END;
jsg_2'# ' LANGUAGE 'plpgsql';
CREATE
jsg_2=# select myfun('en',0);
NOTICE: Error occurred while executing PL/pgSQL function myfun
NOTICE: line 5 at open
ERROR: Attribute 'en' not found
</code>

The Function intially gets parsed, but when called with the parameter, it
seems that no quotes are around the first variable.

What am I missing?

Thanks in advance.

albert.

__________________________________________________________________
Abbonati a Tiscali!
Con Tiscali By Phone puoi anche ascoltare ed inviare email al telefono.
Chiama Tiscali By Phone all' 892 800 http://byphone.tiscali.it

Browse pgsql-novice by date

  From Date Subject
Next Message alberto bolchini 2002-04-20 10:47:23 Correctly quoting inside plpgsql functions
Previous Message Tom Lane 2002-04-20 03:05:44 Re: algebraic rewriting