A trigger can only apply to a single table, so why would you need a variable which would contain the table name?
You already have the explicit context -- you define the trigger. So, if you want a variable, declare it and assign the value you want…
From: firstname.lastname@example.org [mailto:email@example.com]
On Behalf Of W O
Sent: Friday, November 08, 2013 9:00 PM
Subject: Re: [firebird-support] Table and Sequence names by reference
Really it would be nice to have the table's name when you are inside a trigger.
On Fri, Nov 8, 2013 at 9:18 PM, Daniel L. Miller <dmiller@...> wrote:
On 11/7/2013 3:45 PM, Ann Harrison wrote:
On Thu, Nov 7, 2013 at 2:09 PM, Daniel L. Miller <dmiller@...> wrote:
Is it possible to refer to internal structures by reference in PSQL?
Err, reference, usually yes. Change? Probably not. Basically, PSQL is
limited to DML - not DDL.
Ok - can you please clarify what I CAN do? In particular:
1. From within an insert/update trigger, is there a variable that provides the table name? Or, if I'm trying to use a common stored procedure, would I call it from the trigger using the table name as a literal string parameter?
2. Even if the DDL statement I used was wrong (and I admit that - I pasted it without going through it first) can you show me a valid DML? Something like "SELECT * FROM :tablename"?
3. My overly paranoid belt-and-suspenders isn't going to remain in production code (I hope). I had that both as a safeguard and as an example to another programmer I'm working with. The production code would just have the "standard" check to see if an id
was passed, and otherwise perform the assignment of "new.id = NEXT VALUE FOR sequence". But I'd like to have that code structure in a stored procedure so my triggers are basically just one line. Is that wrong?