db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Satheesh Bandaram <sathe...@Sourcery.Org>
Subject Re: trigger
Date Tue, 08 Nov 2005 19:48:07 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
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.
(<a class="moz-txt-link-freetext" href="http://db.apache.org/derby/docs/10.0/manuals/develop/develop53.html#HDRSII-SPECIAL-45786">http://db.apache.org/derby/docs/10.0/manuals/develop/develop53.html#HDRSII-SPECIAL-45786</a>)<br>
<br>
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)<br>
<br>
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.<br>
<br>
Satheesh<br>
<br>
Veaceslav Chicu wrote:
<blockquote cite="mid4370CBA8.8060308@infologic.fr" type="cite">
  <pre wrap="">Hello,
thank you for reply

I want an example for:
<a class="moz-txt-link-freetext" href="http://db.apache.org/derby/docs/10.1/devguide/cdevspecial49460.html">http://db.apache.org/derby/docs/10.1/devguide/cdevspecial49460.html</a>

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

best regards,
Slavic

Dag H. Wanvik wrote:
  </pre>
  <blockquote type="cite">
    <blockquote type="cite">
      <blockquote type="cite">
        <blockquote type="cite">
          <blockquote type="cite">
            <blockquote type="cite">
              <pre wrap="">"Veaceslav" == Veaceslav Chicu <a class="moz-txt-link-rfc2396E"
href="mailto:cs@infologic.fr">&lt;cs@infologic.fr&gt;</a> wrote:
              </pre>
            </blockquote>
          </blockquote>
        </blockquote>
      </blockquote>
    </blockquote>
    <pre wrap="">Veaceslav&gt; 
Veaceslav&gt; where I can read or find examples for triggers?

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

<a class="moz-txt-link-freetext" href="http://db.apache.org/derby/docs/10.1/devguide/cdevspecial27163.html">http://db.apache.org/derby/docs/10.1/devguide/cdevspecial27163.html</a>
<a class="moz-txt-link-freetext" href="http://db.apache.org/derby/docs/10.1/ref/rrefsqlj43125.html">http://db.apache.org/derby/docs/10.1/ref/rrefsqlj43125.html</a>

Dag


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


  </pre>
</blockquote>
</body>
</html>


Mime
View raw message