how to append root node to xml data in oracle [message #461912] |
Tue, 22 June 2010 02:04 |
madhavi babburi
Messages: 117 Registered: May 2009 Location: Hyderabad
|
Senior Member |
|
|
Hi,
How to append root node (as ROWSET) to a variable in pl/sql.
I have the below xml data in a variable. I want to append a root node to the xml data exists in the variable.
I have the below data in a variable.
<ROW>
<TABLESPACE_T>
<VERS_MAJOR>1</VERS_MAJOR>
<VERS_MINOR>0 </VERS_MINOR>
</TABLESPACE_T>
</ROW>
finally i'm expecting the below xml data.
<ROWSET>
<ROW>
<TABLESPACE_T>
<VERS_MAJOR>1</VERS_MAJOR>
<VERS_MINOR>0 </VERS_MINOR>
</TABLESPACE_T>
</ROW>
</ROWSET>
Which function is useful?
Regards,
Madhavi.
|
|
|
|
Re: how to append root node to xml data in oracle [message #461937 is a reply to message #461934] |
Tue, 22 June 2010 03:24 |
madhavi babburi
Messages: 117 Registered: May 2009 Location: Hyderabad
|
Senior Member |
|
|
Hi Michel,
I have tried but get error.
my procedure and error is
SQL> CREATE OR REPLACE PROCEDURE SYS.Database_Import2
2 AUTHID CURRENT_USER
3 AS
4 V_Objtype VARCHAR2(200);
5 V_Cnt NUMBER := 1;
6 V_Xml XMLTYPE;
7 V_Xml1 XMLTYPE;
8 BEGIN
9 FOR I IN ( SELECT Rowid, Obj_Id, Repos FROM sys.DDI_REPOS_T WHERE OBJ_ID <25 ORDER BY Obj_Id)
LOOP
10 SELECT Obj_Tp_Nm INTO V_Objtype FROM DDI_OBJ_TP_T WHERE Obj_Tp_Id IN (SELECT Obj_Tp_Id FRO
M DDI_OBJ_DEF_T WHERE Obj_Id = I.Obj_Id);
11 DBMS_OUTPUT.PUT_LINE('Object type is ' || V_Objtype);
12 LOOP
13 SELECT EXTRACT (I.REPOS, 'ROWSET/ROW['||V_CNT ||']') INTO V_XML FROM DUAL;
14 EXIT WHEN V_XML IS NULL;
15 V_XML1 := <ROWSET>||V_XML||</ROWSET> ;
16 INSERT INTO ABC VALUES (I.OBJ_ID, V_XML1);
17 V_CNT := V_CNT+1;
18 END LOOP;
19 V_cnt := 1;
20 END LOOP;
21 END;
22 /
Warning: Procedure created with compilation errors.
SQL> show errors
Errors for PROCEDURE SYS.DATABASE_IMPORT2:
LINE/COL ERROR
-------- -----------------------------------------------------------------
15/26 PLS-00103: Encountered the symbol "<" when expecting one of the
following:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall merge time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
<an alternatively-quoted string literal with character set
specification>
<an alternatively-quoted S
Regards,
Madhavi.
|
|
|
|
Re: how to append root node to xml data in oracle [message #461943 is a reply to message #461940] |
Tue, 22 June 2010 03:37 |
madhavi babburi
Messages: 117 Registered: May 2009 Location: Hyderabad
|
Senior Member |
|
|
i have tried like that also but another error.
V_XML1 := '<ROWSET>'||V_XML||'</ROWSET>' ;
PLS-00306: wrong number or types of arguments in call to '||'
i used two single quotes also like below.
V_XML1 := ''<ROWSET>''||V_XML||''</ROWSET>'' ;
error is..
ERROR line 15, col 35, ending_line 15, ending_col 35, Found '>', Expecting: ; -or- OR -or- AND -or- || -or- / -or- ** -or- (+) -or- % . [ -or- : @ CASE CONNECT_BY_ROOT decimal number EXISTS FALSE float integer NEW PRIOR SQL TRUE -or- ( * + - AT CONTINUE CURSOR DAY identifier MOD MODEL MULTISET NOT NULL REM string THE WHEN YEAR
[Updated on: Tue, 22 June 2010 03:39] Report message to a moderator
|
|
|
|
|
|