Re: Quotes, double quotes...

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: António M(dot) Rodrigues <amcrgrodrigues(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Quotes, double quotes...
Date: 2013-09-30 06:48:15
Message-ID: 20130930064815.GB18650@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On nie, wrz 29, 2013 at 02:09:54 +0100, António M. Rodrigues wrote:
> The code is the following:
>
> -----------------------------------------------------
> DO $$
> DECLARE
> i integer;
> BEGIN
> FOR i IN (select nn from numeros)
> LOOP
> EXECUTE
> 'create table contagio' || i || ' as
> SELECT *
> FROM pgr_drivingdistance("

" character is not for strings - it's for identifiers.

if you want to have string within string you have following options:
a. multiply ' - i.e. use '' (not ")
b. use $ quotation

so you can:
execute 'whatever ''sub string'' anything ';
or
execute 'whatever $sub$sub string$sub$';

depesz

--
The best thing about modern society is how easy it is to avoid contact with it.
http://depesz.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2013-09-30 11:38:05 Re: logging statements in PostgreSQL
Previous Message Adrian Klaver 2013-09-29 19:18:15 Re: Trouble installing psycopg2