hi!

i was playing around with a TRIGGER AFTER INSERT and i think i found a
mismatch between the documentation and the kernel (.18 and .20):

---
CREATE TABLE foo (oid fixed(30,0), sid fixed(30,0),
                 constraint pk primary key (oid,sid))            
CREATE TABLE bar (oid fixed(30,0), sid fixed(30,0),
                  constraint pk primary key (oid))
---

bar is to contain the highest sid value inserted for each oid into foo.

---
CREATE TRIGGER barfoo FOR foo AFTER INSERT EXECUTE (
 if NEW.sid = 0
 then INSERT INTO raimi.bar (oid,sid) VALUES(:NEW.oid, :NEW.sid)
 else UPDATE raimi.bar (sid) values (:NEW.sid) KEY oid=:NEW.oid;
)
---
results in -8010: table name must be in from list with the position
of "NEW.sid"... well this worked:

---
CREATE TRIGGER barfoo FOR foo AFTER INSERT EXECUTE (
 if sid = 0
 then INSERT INTO raimi.bar (oid,sid) VALUES(:NEW.oid, :NEW.sid)
 else UPDATE raimi.bar (sid) values (:NEW.sid) KEY oid=:NEW.oid;
)
---

... i just left out the "NEW." in the conditional. 

the docs say that for insert-triggers the variable "NEW.<columnname>" is
created automatically... which is obviouslu true when the variable is
used as parameter for a DML statement. in my conditional the variable is
not available, given me a weird error message (again)...

is it a bug?
        (Finger-on-a-TRIGGER-)Raimund

-- 
Raimund Jacob
                                                 \|/ ____ \|/
Pinuts Media+Science GmbH                        "@'/ ,. \`@"
Potsdamer Str. 96                                /_| \__/ |_\
D-10785 Berlin                                      \__U_/
http://www.pinuts.de/ voice: +49 30 590090313 fax: +49 30 590090390
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to