PHP, xquery

Hello!

I just want to add two elements on the same node using “do insert into” command of xquery method. Unfortunately I got the following error code:


Tamino Error 6451: Conflicting update operations (XQuery Update Request processing) (Trying to perform two InsertInto operations against the same node.)


In my database I have got the data:



Atkins
Paul

Male



I just want to have the following data:



Atkins
Paul
J.
Prof.

Male



How should I fix my source code?

In advance, thanks a lot!

best regards,
Dariusz Baumann

PS.

Here is code:
-----------------
<?php

header("Content-Type: text/html; charset=UTF-8");

include "TaminoAPI.php";
include "TaminoHelperFunctions.php";

$PC_HOST = "localhost";
$PC_PORT = "80";
$PC_DATABASE = "mydb";
$PC_COLLECTION = "Hospital";
$PC_DOCTYPE = "patient";
$PC_ENCODING = "UTF-8";
$PC_USERNAME = "";
$PC_PASSWORD = "";

$tamino = &new TaminoAPI($PC_HOST,
$PC_PORT,
$PC_DATABASE,
$PC_USERNAME,
$PC_PASSWORD);

$tamino->setCollection($PC_COLLECTION);

$tamino->setEncoding($PC_ENCODING);

$surname = "Atkins";
$middlename = "J.";
$title = "Prof.";

$xquery = "update for \$a in input()/$PC_DOCTYPE ".
"where \$a/name/surname = \"$surname\" ".
"do ".
"(".
"insert $middlename into \$a/name ".
"insert $title into \$a/name ".
")";

if (!($tamino->xquery($xquery)))
{
echo "ERROR
";
thfPrintError($tamino);
}
else
{
echo "OK.
";
}
?>
-----------------

Hi Dariusz,

As you have seen it is not possible to perform multiple updates to the same node in a single operation. Since both new nodes (middlename, title) are being inserted sequentially into name you could an issue a single xquery-update such as:

update for $a in input()/patient
let $k := J.Prof.
where $a/name/surname = “Atkins”
do
(
insert $k/* into $a/name
)

Hope this helps.

Stuart Fyffe-Collins
Software AG (UK) Ltd.