I have given the following table This table has XML tags and values and optionally reference the original tag.
Global temporary table XML_TAG_VAL Create (Obije_aidi number - unique to a full XML document ID number - Unique every tag VARCHAR2 (1000 BYTE), - Name Tag VAL CLOB, - tag value LVL number - Tags ATTR_ID nUMBER depth - in Tag_ attr foreign key table (after) PARENT_ID nUMBER - id parent tag (xml_tag_val.id)) Committee Delete rows Nakac; Insert a very simple test data in this table ...
xml_tag_val enter values (1,1, A, blank, 1, null, faucet); Insert Xml_tag_val values (1,2, 'b', 'b-value', 2, blank, 1); Insert Xml_tag_val values (1,3, 'b', 'b-value 2', 2, blank, 1); Now what I have to do is generate XML for a given client interface. Therefore the result should be:
& lt; A & gt; & Lt; P & gt; B value & lt; / P & gt; & Lt; B & gt; B-value 2 & lt; / B & gt; & Lt; / A & gt; Therefore SQL using a hand xmllelement for this specific case will not be an issue. But how can I deepen the path without knowing the path to Gmail? I know that every child tells his parents.
1 Edit:
I've found a way to use recursive queries to create XML I have the following query: declare l_qry_ctx dbms_xmlgen.ctxhandle; L_result Clubs; L_obj_id number: = 1; Start l_qry_ctx: = dbms_xmlgen.newcontextFromHierarchy ( 'select level, xmlelement (tag, val) from oranetted_plugin.xml_tag_val, where obj_id =' || l_obj_id || Start 'parent_id parent_id = is not connected to the first ID); L_result: = dbms_xmlgen.getxml (l_qry_ctx); Dbms_output.put_line (l_result); End; The problem is that the name of the tag can not be feeds from the sqls result shown as "tag" instead of "A" or "B" tags. & lt; TAG & gt; & Lt; Tag & gt; B value & lt; / Tags & gt; & Lt; TAG & gt; B-value 2 & lt; / TAG & gt; & Lt; / Tags & gt; Any ideas to get around this?
Well, it's ugly but probably desired results
Declare l_qry_ctx dbms_xmlgen.ctxhandle; L_result Clubs; L_expression varchar2 (32767); L_obj_id number: = 1; Start for R (select a different tag from xml_tag_val) loop l_expression: = l_expression || 'कब' '' || R Tieg || '' 'Then excelement (' || rataag || ', val)'; End loop; L_expression: = 'Case tag' || L_expression || ' End'; L_qry_ctx: = dbms_xmlgen.newcontextFromHierarchy ('select level', 'l_expression ||' to xml_tag_val where obj_id = '|| l_obj_id' begins with parent_id parent_id = connects to first ID); L_result: = dbms_xmlgen.getxml (l_qry_ctx); Dbms_output.put_line (l_result); End; / ... but you have to remember about the case expression limit.
Comments
Post a Comment