Problems when using XQuery to create elements

Hi!

I want to add elements to Tamino database using Xquery. I try to add data using xquery with this syntax:

$query_1 =
‘element ACTBOOKS
{
element ACTBOOK
{
element CUSTID {“44444”},
element ACTID2 {“7777772”},
element ACTNAME {“Rafting”},
element START {“20040404”},
element STOP {“20040404”}
}
}’;


if (!($tamino2->xquery($query_1)))
{
thfPrintError($tamino2);
echo “into the error”;
}
else
.
.
.
.

ACTBOOKS is the root element.

I get no Tamino error when using this syntax, but the database is not updated with the element.

Can someone explain why the database isn’t updated? ( I can add elements using xml files with the statement processData )

Any help is appreciated!

Thanks in advance!

Regards,
Tom-Erik Valso
Oslo, Norway

:slight_smile:

Hello Tom-Erik,

what you did is you basically created an XML document but did not insert it into Tamino. If you send the XQuery expression the way you have specified it to Tamino using the InteractiveInterface you will see that the XML document is correctly created by the XQuery engine in Tamino, but it is simply displayed as a result and not stored into Tamino. Since this is a valid XQuery espression you did not get an error. Using XQuery you can currently only delete or modify existing documents in Tamino, but you cannot create new ones. This is not a restriction of the PHP API. To insert new documents into Tamino you will need to use the “process” command.

regards,
Heiko

Hello Heiko,

Ok!

I will continue to write the XML files to disk (as I originally did), and then upload them into Tamino.

Thanks a lot for your answer!

Best regards,
Tom-Erik

:slight_smile:

You could use the process command and directly send the contents of a variable to Tamino - I don’t quite see why you would want to write the XML documents to disk first.

regards,
Heiko

Hi!

Ok!

You are absolutely correct. I don’t want to write the XML to files, so I guess I misunderstood ho :)w the process command could be used.

Greetings,
Tom-Erik