Concatenating String Literals in pgsql

Started by Raymondover 22 years ago2 messagesgeneral
Jump to latest
#1Raymond
support@bigriverinfotech.com

How does one concat string literals in pgsql ?

The compiler complains about the concat operator in the following code
fragment:

RAISE EXCEPTION
''SELECT DISTINCT "t1"."usesysid" '' ||
''INTO userID '' ||
''FROM "pg_user" AS "t1" '' ||
''WHERE "t1"."usename" = current_user '' ||
''NOT FOUND'';

Thanks in advance.

Raymond

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Raymond (#1)
Re: Concatenating String Literals in pgsql

Raymond <support@bigriverinfotech.com> writes:

The compiler complains about the concat operator in the following code
fragment:

RAISE EXCEPTION
''SELECT DISTINCT "t1"."usesysid" '' ||
''INTO userID '' ||

RAISE EXCEPTION doesn't support expressions in its arguments, IIRC.
The format has to be a simple string literal, and anything to be plugged
into it has to be a variable reference.

So, do the concatenation beforehand.

regards, tom lane