By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

problem with variable

P: 7
Hello everyone

When the trigger executes the function which I copy below:

Expand|Select|Wrap|Line Numbers
  1. IF (TG_OP = 'UPDATE') THEN
  2. EXECUTE 'CREATE TABLE '||NEW.nome_tabella||' (ordinativo serial PRIMARY KEY
  3. CHECK (nome_tabella = '||NEW.nome_tabella||'::text))
  4. INHERITS (madre);
  5.  
first use of the variable '||NEW.nome_tabella||' is correct and the table is created with the name, for example "azienda_vallone", but I do not know why, the second use of the variable is incorrect because the CHECK insert on table is nome_tabella = azienda_vallone.*.
I can not understand why postgresql insert point and asterisk at the end of the variable.
if anyone can give me some suggestions on how to resolve...

thank you very much
Luca
Jun 9 '10 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 700
@sentenza
NEW is not a variable but a 'table' (virtual one).
I guess that 'madre' table contains column nome_tabella, does it?
Maybe you should first copy value NEW.nome_tabella to some variable (using := operator) and then use the variable into check statement.
Jun 13 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.