Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group