Thread: quotes etc

quotes etc

From
John Fabiani
Date:
Hi,
I would have thought that there would be a simple built-in function that would 
escape the quotes as ('D' Andes')  to ('D\' Andes').  But I did not see 
anything?

I am I wrong?

Johnf


Re: quotes etc

From
Kenneth Marshall
Date:
On Tue, Feb 22, 2011 at 12:26:41PM -0800, John Fabiani wrote:
> Hi,
> I would have thought that there would be a simple built-in function that would 
> escape the quotes as ('D' Andes')  to ('D\' Andes').  But I did not see 
> anything?
> 
> I am I wrong?
> 
> Johnf
> 

The manual goes over many permutations of the escape process and
what options can be used in each case. I would start there, because
for example, escaping a "'" in SQL uses two "'"s: i.e. 'D' Andes'
becomes 'D'' Andes' I think. Procedural languages and libpq can
offer many other options for escape processing.

Cheers,
Ken


Re: quotes etc

From
Adrian Klaver
Date:
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">OnTuesday, February 22, 2011 12:26:41 pm John Fabiani wrote:<p style=" margin-top:0px;
margin-bottom:0px;margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">> Hi,<p
style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">>I would have thought that there would be a simple built-in function that<p style="
margin-top:0px;margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">>would escape the quotes as ('D' Andes') to ('D\' Andes'). But I did not<p style="
margin-top:0px;margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">>see anything?<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;
-qt-block-indent:0;text-indent:0px; -qt-user-state:0;">> <p style=" margin-top:0px; margin-bottom:0px;
margin-left:0px;margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">> I am I wrong?<p style="
margin-top:0px;margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;
-qt-block-indent:0;text-indent:0px; -qt-user-state:0;">> Johnf<p style="-qt-paragraph-type:empty; margin-top:0px;
margin-bottom:0px;margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><p style="
margin-top:0px;margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">Dollarquoting ? :<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px;
margin-left:0px;margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><p style=" margin-top:0px;
margin-bottom:0px;margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">http://www.postgresql.org/docs/9.0/interactive/sql-syntax-lexical.html<pstyle=" margin-top:0px;
margin-bottom:0px;margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><a
name="SQL-SYNTAX-DOLLAR-QUOTING"></a><spanstyle=" font-size:large;">4</span><span style=" font-size:large;">.1.2.4.
Dollar-QuotedString Constants</span><p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px;
margin-left:0px;margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><p style=" margin-top:0px;
margin-bottom:0px;margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">test(5432)aklaver=>SELECT$$D' Andes$$;<p style=" margin-top:0px; margin-bottom:0px;
margin-left:0px;margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"> ?column? <p style="
margin-top:0px;margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">----------<pstyle=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;
-qt-block-indent:0;text-indent:0px; -qt-user-state:0;"> D' Andes<p style="-qt-paragraph-type:empty; margin-top:0px;
margin-bottom:0px;margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><p style="
margin-top:0px;margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;
-qt-user-state:0;">--<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;
-qt-block-indent:0;text-indent:0px; -qt-user-state:0;">Adrian Klaver<p style=" margin-top:0px; margin-bottom:0px;
margin-left:0px;margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">adrian.klaver@gmail.com 

Re: quotes etc

From
Emi Lu
Date:
On 02/22/2011 04:18 PM, Adrian Klaver wrote:
> On Tuesday, February 22, 2011 12:26:41 pm John Fabiani wrote:
>
>  > Hi,
>
>  > I would have thought that there would be a simple built-in function that
>
>  > would escape the quotes as ('D' Andes') to ('D\' Andes'). But I did not
>
>  > see anything?
>
>  >
>
>  > I am I wrong?
>
>  >
>
>  > Johnf
>
> Dollar quoting ? :
>
> http://www.postgresql.org/docs/9.0/interactive/sql-syntax-lexical.html
>
> 4.1.2.4. Dollar-Quoted String Constants
>
> test(5432)aklaver=>SELECT $$D' Andes$$;
>
> ?column?
>
> ----------
>
> D' Andes

I like this $str$....$str$ very much!

Vote for this!
--
Lu Ying