concatenation in procedures.
От | Shaun Thomas |
---|---|
Тема | concatenation in procedures. |
Дата | |
Msg-id | Pine.LNX.4.33L2.0109131106180.2334-100000@hamster.lee.net обсуждение исходный текст |
Список | 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@townnews.com AIM : trifthen | | Web : hamster.lee.net | | | | "Most of our lives are about proving something, either to | | ourselves or to someone else." | | -- Anonymous | +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
В списке pgsql-general по дате отправления: