On 11/7/2013 3:45 PM, Ann Harrison wrote:
On Thu, Nov 7, 2013 at 2:09 PM, Daniel L. Miller <[email protected]
<mailto:[email protected]>> 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?
--
Daniel