Re: problem with variable
От | coviolo@libero.it |
---|---|
Тема | Re: problem with variable |
Дата | |
Msg-id | 24107154.2662051276155100771.JavaMail.defaultUser@defaultHost обсуждение исходный текст |
Ответ на | problem with variable ("coviolo@libero.it" <coviolo@libero.it>) |
Список | pgsql-novice |
ok the latest version works perfectly. Many thanks to all Ciao Luca >----Messaggio originale---- >Da: esiotrot@gmail.com >Data: 09/06/2010 16.54 >A: "coviolo@libero.it"<coviolo@libero.it> >Cc: <pgsql-novice@postgresql.org> >Ogg: Re: [NOVICE] problem with variable > >On 9 June 2010 16:51, Michael Wood <esiotrot@gmail.com> wrote: >> Hi >> >> On 9 June 2010 16:24, coviolo@libero.it <coviolo@libero.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@gmail.com> > >-- >Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org) >To make changes to your subscription: >http://www.postgresql.org/mailpref/pgsql-novice >
В списке pgsql-novice по дате отправления: