Quoted identifiers in queries in plpgsql functions. - Mailing list pgsql-general

From Neal Holtz
Subject Quoted identifiers in queries in plpgsql functions.
Date
Msg-id 3D107D1D.C0D4DA70@docuweb.ca
Whole thread Raw
Responses Re: Quoted identifiers in queries in plpgsql functions.  (Masaru Sugawara <rk73@sea.plala.or.jp>)
List pgsql-general
How do I specify quoted identifiers in plpgsql functions?

If the following is in test.sql:

-- begin test.sql
CREATE TABLE Control (
    "Full Name"    varchar(255) NOT NULL PRIMARY KEY,
    "Telephone Number"    varchar(255)
);

INSERT INTO Control ("Full Name","Telephone Number") VALUES
('neal','730-7888');

CREATE OR REPLACE FUNCTION test() RETURNS varchar(255) AS '
DECLARE
    val    varchar(255);
BEGIN
    SELECT INTO val "Telephone Number" FROM Control WHERE "Full
Name"=''neal'';
    RETURN val;
END;
' LANGUAGE 'plpgsql';
-- end test.sql

I get syntax errors when I try to execute the function:

    BaseContacts_Devel=# \i test.sql
    . . .
    BaseContacts_Devel=# select test();
    NOTICE:  plpgsql: ERROR during compile of test near line 4
    ERROR:  unterminated " in name "Telephone

I've tried as many combinations of escaping as I can think of,
but nothing has worked for me so far.

I'll be grateful for any help.

thanks
neal


--
Neal Holtz                             http://www.docuweb.ca/~nholtz
Dept. of Civil and Environmental Engineering,   Carleton University,
Ottawa, Ontario, Canada K1S 5B6.                   nholtz@docuweb.ca

pgsql-general by date:

Previous
From: "Joel Burton"
Date:
Subject: Re: initdb dies during IpcSemaphoreCreate under BSD jail
Next
From: Tom Lane
Date:
Subject: Re: CAST(null as date)...