Concatenating String Literals in pgsql

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Raymond

    Concatenating String Literals in pgsql

    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"."usesy sid" '' ||
    ''INTO userID '' ||
    ''FROM "pg_user" AS "t1" '' ||
    ''WHERE "t1"."usena me" = current_user '' ||
    ''NOT FOUND'';

    Thanks in advance.

    Raymond

    ---------------------------(end of broadcast)---------------------------
    TIP 1: subscribe and unsubscribe commands go to majordomo@postg resql.org

  • Tom Lane

    #2
    Re: Concatenating String Literals in pgsql

    Raymond <support@bigriv erinfotech.com> writes:[color=blue]
    > The compiler complains about the concat operator in the following code
    > fragment:[/color]
    [color=blue]
    > RAISE EXCEPTION
    > ''SELECT DISTINCT "t1"."usesy sid" '' ||
    > ''INTO userID '' ||[/color]

    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

    ---------------------------(end of broadcast)---------------------------
    TIP 7: don't forget to increase your free space map settings

    Comment

    Working...