Triggers don't have explicit syntax to throw Exceptions. The URL you mentioned is generally talking about system generated exceptions, I think. Based on your first post, it seems you are looking for a way to raise a user defined exception from a trigger. If this is true, then there is only very brief mention of this in Derby manuals. (http://db.apache.org/derby/docs/10.0/manuals/develop/develop53.html#HDRSII-SPECIAL-45786)

I think it should be possible to raise an Exception for the case you mentioned at the end... You can have a user defined function which raises a user-defined Exception and place that function in the select list. (without WHEN clause)

Derby doesn't have SQL stored procedure language yet. That would have allowed multi-statement triggers and ability to throw exceptions easily. There was a proposal from Dan on how to enhance Derby to add this procedure language.

Satheesh

Veaceslav Chicu wrote:
Hello,
thank you for reply

I want an example for:
http://db.apache.org/derby/docs/10.1/devguide/cdevspecial49460.html

a trigger that throws an exception (if it's not difficult an example
with catch also)

best regards,
Slavic

Dag H. Wanvik wrote:
  
"Veaceslav" == Veaceslav Chicu <[EMAIL PROTECTED]> wrote:
              
Veaceslav> 
Veaceslav> where I can read or find examples for triggers?

Have a look in the Derby Developer's Guide and Derby Reference, here:

http://db.apache.org/derby/docs/10.1/devguide/cdevspecial27163.html
http://db.apache.org/derby/docs/10.1/ref/rrefsqlj43125.html

Dag


Veaceslav> thank you,
Veaceslav> Slavic
Veaceslav> 
Veaceslav> Veaceslav Chicu wrote:
Veaceslav> > nobody know?
Veaceslav> > 
Veaceslav> > best regards,
Veaceslav> > Slavic
Veaceslav> > 
Veaceslav> > Veaceslav Chicu wrote:
Veaceslav> > 
Veaceslav> >>Hello,
Veaceslav> >>
Veaceslav> >>how can I do that in derby?:
Veaceslav> >>CREATE TRIGGER acc.ins_doc NO CASCADE BEFORE INSERT ON acc.doc
Veaceslav> >>	REFERENCING NEW AS N
Veaceslav> >>	FOR EACH ROW MODE DB2SQL
Veaceslav> >>WHEN(
Veaceslav> >>	SELECT FROM period
Veaceslav> >>		WHERE state='O' AND
Veaceslav> >>		N.cdate BETWEEN date_start AND date_end
Veaceslav> >>) SIGNAL SQLSTATE 'ERRCODE' ('ERR MESSAGE')
Veaceslav> >>@
Veaceslav> >>
Veaceslav> >>another question, can I have 2 or more insert/update statements in after
Veaceslav> >>trigger? how I do?
Veaceslav> >>begin atomic
Veaceslav> >>	update 1;
Veaceslav> >>	update 2;
Veaceslav> >>end
Veaceslav> >>@
Veaceslav> >>
Veaceslav> >>thank you,
Veaceslav> >>Slavic
Veaceslav> >>
Veaceslav> > 
Veaceslav> > 
Veaceslav> > 
Veaceslav> 
    



  

Reply via email to