Im folgenden Code muss zuerst ein Element hinzugefügt werden, im restlichen Code wird ein Attribut namens t erstellt oder aktualisiert.Mehrere Operationen gleichzeitig bearbeiten
declare
LOG_REFERENCE xmltype:=xmltype('<log />');
begin
select XMLQuery('
copy $p := $p1 modify insert node <update data="{$p2}" />
as last into $p/log
return $p
' PASSING LOG_REFERENCE AS "p1", to_char(systimestamp) AS "p2" RETURNING CONTENT)
INTO LOG_REFERENCE from dual;
select XMLQuery('
copy $i := $p1 modify(
if (fn:exists($i/log[1]/@t)) then (
replace value of node $i/log[1]/@t with $p2
) else (
insert node attribute t {$p2} into $i/log[1]
)
)
return $i
' PASSING LOG_REFERENCE AS "p1", to_char(systimestamp) AS "p2" RETURNING CONTENT)
INTO LOG_REFERENCE from dual;
dbms_output.PUT_LINE(LOG_REFERENCE.getClobVal());
end;
Mein Problem ist, dass ich die beiden ändern in eine xquery Aufruf wie dieses
declare
LOG_REFERENCE xmltype:=xmltype('<log />');
begin
select XMLQuery('
copy $p := $p1 modify(
insert node <update data="{$p2}" />
as last into $p/log
)
copy $i := $p modify(
if (fn:exists($i/log[1]/@t)) then (
replace value of node $i/log[1]/@t with $p2
) else (
insert node attribute t {$p2} into $i/log[1]
)
)
return $i
' PASSING LOG_REFERENCE AS "p1", to_char(systimestamp) AS "p2" RETURNING CONTENT)
INTO LOG_REFERENCE from dual;
dbms_output.PUT_LINE(LOG_REFERENCE.getClobVal());
end;
In meinem Kopf das ist richtig, aber natürlich im, fehlt etwas beitreten wollten. Oder es kann nicht in Orakel Xquery getan werden?
die Fehlermeldung, die gegeben wurde:
ORA-19114: XPST0003 - Fehler den XQuery-Ausdrucks bei der Analyse: LPX-00801: XQuery Syntaxfehler bei 'Kopie' 7 Kopie $ i: = $ p ändern ( -^ORA-06512: em Linie 5