Quoted identifiers in queries in plpgsql functions.

From: Neal Holtz <nholtz(at)docuweb(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Quoted identifiers in queries in plpgsql functions.
Date: 2002-06-19 12:46:21
Message-ID: 3D107D1D.C0D4DA70@docuweb.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)docuweb(dot)ca

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-06-19 12:57:24 Re: CAST(null as date)...
Previous Message Joel Burton 2002-06-19 12:39:34 Re: initdb dies during IpcSemaphoreCreate under BSD jail