Re: Function Syntax involving pipes and ' marks?

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Ruben Gouveia <rubes7202(at)gmail(dot)com>
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Function Syntax involving pipes and ' marks?
Date: 2008-09-10 00:58:48
Message-ID: 20080910005847.GH4223@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Ruben Gouveia escribió:
> No matter how many times i try, i can't seem to get the write amount of '
> marks around the date parameters in my v_where declaration. What am i doing
> wrong here?

Apparently you're not aware that you can nest the $$ quote marks. You
could just use $a$ to assign to the varchar, and use ' inside that
string to get the literal '. Of course, you could use also $b$ instead
of a plain single quote.

That is,
v_where varchar(256) := $a$ where m.jb_date < $a$||p_date + integer '1'||
$a$ and m.jb_date >='$a$ ||p_date|| $a$'$a$;

or (harder to read)

v_where varchar(256) := $a$ where m.jb_date < $a$||p_date + integer '1'||
$a$ and m.jb_date >=$b$ $a$ ||p_date|| $a$ $b$ $a$;

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Kota, Prasoona 2008-09-10 13:57:50 FW: Help- post gress sql error
Previous Message Ruben Gouveia 2008-09-09 23:20:40 Function Syntax involving pipes and ' marks?