Re: Function Syntax involving pipes and ' marks? - Mailing list pgsql-sql

From Alvaro Herrera
Subject Re: Function Syntax involving pipes and ' marks?
Date
Msg-id 20080910005847.GH4223@alvh.no-ip.org
Whole thread Raw
In response to Function Syntax involving pipes and ' marks?  ("Ruben Gouveia" <rubes7202@gmail.com>)
List 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$
andm.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.


pgsql-sql by date:

Previous
From: "Ruben Gouveia"
Date:
Subject: Function Syntax involving pipes and ' marks?
Next
From: "Kota, Prasoona"
Date:
Subject: FW: Help- post gress sql error