Hi all,

I am trying to implement the cascade delete by using triggers. I got 
stuck at the following point:

- when I delete a master node, I want to delete all the detail nodes 
that belong to the master. However, nodes are not under the master, but 
in the same level with master. Here is the example:

<bill id="b1" />
<bill id="b2" />
<item id="1" bill="b1" />
<item id="2" bill="b1" />
<item id="3" bill="b2" />
<item id="4" bill="b2" />

I cannot place items under the bill, so I need to delete all the items 
that belong to the given bill.

Now, here is the problem:
- if I create a statement-level trigger, it does not have the $OLD and 
$NEW variables, so I don't know which item(s) to delete;
- if I create a node-level trigger, it cannot contain UPDATE statement, 
or at least I don't know how to do it. Here is the quote from the 
Programming Guide:

"It is a mandatory requirement that node-level trigger action ends with 
an XQuery query, while this is optional for actions of statement-level 
triggers."

What does it mean to "end with"? Can it contain UPDATE statement before 
xQuery query?

Here is the code that I would like to have working:

CREATE TRIGGER "CascadeDelete"
AFTER DELETE
ON collection('cascadeexample')/bills/bill
FOR EACH NODE
DO {
   UPDATE
   DELETE
   fn:doc("bills", "cascadeexample")/bills/item[@bill=$OLD/@id];
}

I get the following error:
ERROR SE3210 Trigger action in a node-level trigger must end with an 
XQuery query. Details: at (6:3)

Can I put the UPDATE statement and somehow "end the code" with the XQuery?

Best regards,

Milan




------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Sedna-discussion mailing list
Sedna-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sedna-discussion

Reply via email to