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