Raimund Jacob wrote:

> 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?

Let's say, the documentation was not changed according to the
implementation:
because NEW together with inserts and OLD together with delete is
superfluous
it was not allowed in any case. Now it is allowed in SQL-statements, but is
not
allowed with the other statements (with nearly all other statements).
We will change the docu to avoid confusion.

Elke
SAP Labs Berlin 
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to