Re: problem with variable

From: "coviolo(at)libero(dot)it" <coviolo(at)libero(dot)it>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: problem with variable
Date: 2010-06-09 15:23:36
Message-ID: 18239246.2936121276097016430.JavaMail.defaultUser@defaultHost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

tnx Tim an tnx Michael

I'll try tonight...Tomorrow I hope I have therefore resolved.

bye
Luca

>----Messaggio originale----
>Da: esiotrot(at)gmail(dot)com
>Data: 09/06/2010 16.54
>A: "coviolo(at)libero(dot)it"<coviolo(at)libero(dot)it>
>Cc: <pgsql-novice(at)postgresql(dot)org>
>Ogg: Re: [NOVICE] problem with variable
>
>On 9 June 2010 16:51, Michael Wood <esiotrot(at)gmail(dot)com> wrote:
>> Hi
>>
>> On 9 June 2010 16:24, coviolo(at)libero(dot)it <coviolo(at)libero(dot)it> wrote:
>>> something like this:
>>>
>>> IF (TG_OP = 'UPDATE') THEN
>>> EXECUTE 'CREATE TABLE '||NEW.nome_tabella||' (ordinativo serial PRIMARY
KEY
>>> CHECK (nome_tabella = '''||NEW.nome_tabella||'''::text))
>>> INHERITS (database_t);
>>>
>>> 3 quotes first and 3 quotes after the second variable?
>>
>> Just a guess, but I think this is what you want:
>>
>> IF (TG_OP = 'UPDATE') THEN
>> EXECUTE 'CREATE TABLE ' || NEW.nome_tabella || ' (ordinativo serial PRIMARY
KEY
>> CHECK (nome_tabella = "' || NEW.nome_tabella || '"::text))
>> INHERITS (database_t);'
>>
>> i.e. you want:
>>
>> CREATE TABLE table_name (x serial PRIMARY KEY
>> CHECK (column_name = "table_name"::text))
>> INHERITS (database_t);
>
>Sorry, I was talking nonsense. You want column_name = 'table_name'
>but because the ' will be inside a quoted string, you need to double
>it. So you were right. Use ...nome_tabella = ''' || NEW.nome_tabella
>|| '''::text...
>
>--
>Michael Wood <esiotrot(at)gmail(dot)com>
>
>--
>Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
>To make changes to your subscription:
>http://www.postgresql.org/mailpref/pgsql-novice
>

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2010-06-09 16:14:47 Re: Transaction manipulation commands in user defined c functions?
Previous Message Michael Wood 2010-06-09 14:54:44 Re: problem with variable