Re: Quotes, double quotes... - Mailing list pgsql-general

From hubert depesz lubaczewski
Subject Re: Quotes, double quotes...
Date
Msg-id 20130930064815.GB18650@depesz.com
Whole thread Raw
In response to Quotes, double quotes...  (António M. Rodrigues <amcrgrodrigues@gmail.com>)
List 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/


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Trouble installing psycopg2
Next
From: Albe Laurenz
Date:
Subject: Re: logging statements in PostgreSQL