Hallo Gerd,

you are right, the syntax of routines in SAP DB seems to be quite irregular 
and is definitely not that what is described in the manual.

e.g. the following code has been rejected with an error message:

create trigger testTrigger1 for myTable after insert execute
(
    if new.Name = 'invalid' then
        stop (-30, 'invalid name');
)

but this one works:

create trigger testTrigger1 for myTable after insert execute
(
    var myname varchar(20);
    set myname = new.Name;
    if myname = 'invalid' then
        stop (-30, 'invalid name');
)

May be an if statement ist not allowed at the beginning of a routine. For me, 
that sounds very strange, but i have no other explanation. And that is not 
the only strange thing i found within the SAP DB procedure language. I didn't 
try to explore it systematically, but generally i think you shouldn't try to 
use triggers in the current version of SAP DB if it is not absolutely 
necessary.

Walter Link

> Hi Walter and rest of the list,
>
> sorry that I forgot to mention this in my last posting, I already
> tested your version and this produces the error:
>
> General error;-7045 POS(243) Parameter spec not allowed
>
> so, I have no idea how to check this NEW value in my insert trigger.
> Following code is not working, but how ???
>
> 1.)
> create trigger tr_blub for table1 after insert execute
>  (
>       if NEW.comment <> 'default comment' then
>       ...
>  )
> 2.)
> create trigger tr_blub for table1 after insert execute
>  (
>       if :NEW.comment <> 'default comment' then
>       ...
>  )
> 3.)
> create trigger tr_blub for table1 after insert execute
>  (
>       if comment <> 'default comment' then
>       ...
>  )
>
>
> thanks in advance ..:GERD:..
>
>

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

Reply via email to