Bugs item #2744564, was opened at 2009-04-08 17:43
Message generated for change (Comment added) made by drideru
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=713730&aid=2744564&group_id=129076
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Triggers
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Konstantin (drideru)
Assigned to: Nobody/Anonymous (nobody)
Summary: INSERT trigger is called upon UPDATE REPLACE
Initial Comment:
The INSERT BEFORE TRIGGER is called when the UPDATE REPLACE is executed. Found
out because there might be another bug, which I will post separately.
CREATE TRIGGER "rwipinfdir:500_insert_site_before"
BEFORE INSERT
ON doc("infrastructure")//site
FOR EACH NODE
DO
{
let $node:=$NEW
(:insert new id:)
let $node:=
<site>
{$node/@*,
attribute {"id"} {concat("site_id_", $idnext)},
$node/*}
</site>
(:insert name:)
let $node:=
<site>
{$node/@*, $node/*}
<name>new site</name>
</site>
(:insert description:)
let $node:=
<site>
{$node/@*, $node/*}
<description>The new site was created but the
information was not customized yet.</description>
</site>
(:insert log:)
...
let $node:=
<site>
{$node/@*, $node/*}
<log>
<createdBy>{string($partner/@id)}</createdBy>
<createTimestamp>{$timestamp}</createTimestamp>
<modifiedBy>{string($partner/@id)}</modifiedBy>
<modifyTimestamp>{$timestamp}</modifyTimestamp>
</log>
</site>
return $node;
}
The INSERT operation is working nicely
UPDATE INSERT <site/> into doc("mydoc")
The UPDATE REPLACE operation strangely (at least for me) executes also the
INSERT BEFORE trigger. With that only section with LOG creates the error.
2009/04/08 17:31:31 database query/update failed (SEDNA Message: ERROR SE3205
Trigger action tries to update a document/collection that is currently updating
by the outer update statement.
Details: mydoc
----------------------------------------------------------------------
>Comment By: Konstantin (drideru)
Date: 2009-04-08 22:15
Message:
Hi, Ivan!
here is the code to execute.
---------------------------- CREATE AN EMPTY DOCUMENT
-------------------------------
create document "test"
---------------------------- CREATE TRIGGER
-----------------------------------------
declare namespace testns="TEST_UPDATE_REPLACE";
CREATE TRIGGER "testns:500_insert_site_before"
BEFORE INSERT
ON doc("test")//site
FOR EACH NODE
DO
{
let $node:=$NEW
(:first check if there are some elements:)
(:that are not allowed to be insert by the user:)
(:insert required subnodes and attributes if they are missing:)
(:insert name:)
let $node:=if(empty($node/name))
then
<site>
{$node/@*, $node/*}
<name>new site</name>
</site>
else $node
(:insert description:)
let $node:=if(empty($node/description))
then
<site>
{$node/@*, $node/*}
<description>The new site was created but the
information was not
customized yet.</description>
</site>
else $node
(:insert log:)
let $user := se:get-property("$user")
let $partner:=doc("test")//partn...@id=$user]
let $timestamp:=adjust-dateTime-to-timezone(current-dateTime(),
xs:dayTimeDuration('PT0H'))
let $node:=if(empty($node/log))
then (
if(exists($partner))
then
<site>
{$node/@*, $node/*}
<log>
<createdBy>{string($partner/@id)}</createdBy>
<createTimestamp>{$timestamp}</createTimestamp>
<modifiedBy>{string($partner/@id)}</modifiedBy>
<modifyTimestamp>{$timestamp}</modifyTimestamp>
</log>
</site>
else
error(xs:QName("testns:insert_site_before"),
concat("Failed to locate the partner node for
the current user '",
$user, "'."))
)
else $node
return $node;
}
------------------------------- INSERT NEW NODES
------------------------------------
update insert <partner id="SYSTEM"/> into doc("test")
update insert <site/> into doc("test")
------------------------------- UPDATE THE NODE
------------------------------------
update replace $site in doc("test")/site with
<site>
<name>new site</name>
<description>The new site was created but the information was not
customized yet.</description>
</site>
----------------------------------------------------------------------
Comment By: Ivan Shcheklein (shcheklein)
Date: 2009-04-08 21:45
Message:
Konstantin, could you provide us an example of the document and exact
queries to reproduce the issue on?
----------------------------------------------------------------------
Comment By: Konstantin (drideru)
Date: 2009-04-08 17:49
Message:
Oh no, will not post the other bug/?. it is already described here. it
appears when the <log> section is inserted. it has two levels.
it does not appear if only <name> or <description> is inserted (UPDATE
REPLACE only).
So totally two bugs.
TRIGGER INSERT BEFORE is called upon UPDATE REPLACE.
Adding a subnode of more than one level deep in this trigger, when it is
called upon UPDATE REPLACE, causes the error SE3205.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=713730&aid=2744564&group_id=129076
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Sedna-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sedna-discussion