Re: back slash separated values

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "surabhi(dot)ahuja" <surabhi(dot)ahuja(at)iiitb(dot)ac(dot)in>
Cc: "PostgreSQL General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: back slash separated values
Date: 2006-03-22 14:29:26
Message-ID: 16094.1143037766@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"surabhi.ahuja" <surabhi(dot)ahuja(at)iiitb(dot)ac(dot)in> writes:
> mod_pattern := mod_of_study || ''\\'' || $2;

If this is in a function body, you need four backslashes not two, for
the same reason that you need to double the quote marks: one level of
quotes and backslashes is eaten when the function body is parsed as a
string literal.

If you are on a recent PG version, you should consider switching to
dollar-quotes for the function body. Then you don't need to double
anything, and the constant looks the same as it would look in plain
SQL: mod_of_study || '\\' || $2;

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2006-03-22 14:29:44 Re: Enforcing serial uniqueness?
Previous Message Tom Lane 2006-03-22 14:23:04 Re: Enforcing serial uniqueness?