From: | Shaun Thomas <sthomas(at)townnews(dot)com> |
---|---|
To: | PostgreSQL general list <pgsql-general(at)postgresql(dot)org> |
Subject: | concatenation in procedures. |
Date: | 2001-09-13 16:53:56 |
Message-ID: | Pine.LNX.4.33L2.0109131106180.2334-100000@hamster.lee.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
So... this may sound stupid, but according to the documentation I've
read, this should be possible.
Why can I do this:
tError := ''Here is some error text. I wanted to wrap it '' ||
''so my code would look nicer. So, I of course '' ||
''thought of concatenation. '';
RAISE EXCEPTION ''%'', tError;
But I can't do this:
RAISE EXCEPTION ''Here is some error text. I wanted to wrap it '' ||
''so my code would look nicer. So, I of course '' ||
''thought of concatenation. '';
And yet the documentation uses this as an example:
RAISE EXCEPTION ''View '' || key || '' not found'';
So I made up an example to test this:
CREATE FUNCTION sp_test()
RETURNS BOOLEAN AS '
DECLARE
tStuff VARCHAR(10) := ''Print Me'';
BEGIN
RAISE EXCEPTION ''I would like to say : '' || tStuff || '', now!'';
RETURN TRUE;
END;
' LANGUAGE 'plpgsql';
Postgres returns this error:
mydb=# SELECT sp_test();
NOTICE: plpgsql: ERROR during compile of sp_test near line 4
ERROR: parse error at or near "|"
Which told me it was whining about the ||'s. So I wrote this:
CREATE FUNCTION sp_test()
RETURNS BOOLEAN AS '
DECLARE
tStuff VARCHAR(10) := ''Print Me'';
BEGIN
RAISE EXCEPTION ''I would like to say : %, now!'', tStuff;
RETURN TRUE;
END;
' LANGUAGE 'plpgsql';
Which returns no errors, and runs as expected.
I first noticed this error in 7.1.1, but it's still around in 7.1.3.
What's the deal?
--
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Shaun M. Thomas INN Database Programmer |
| Phone: (309) 743-0812 Fax : (309) 743-0830 |
| Email: sthomas(at)townnews(dot)com AIM : trifthen |
| Web : hamster.lee.net |
| |
| "Most of our lives are about proving something, either to |
| ourselves or to someone else." |
| -- Anonymous |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
From | Date | Subject | |
---|---|---|---|
Next Message | postgres | 2001-09-13 17:01:17 | Re: Is Perl compiled into Version? |
Previous Message | Ryan Mahoney | 2001-09-13 16:51:22 | Re: business perspective |