Change the default output of dbms_xmlgen.getxml

10g 10.2.0.3

installation program:
create table table_x (column1 varchar2(10), column2 number) 

insert into table_x values('row1',1);

insert into table_x values('row2',2);

commit;
Select using getxml:
select dbms_xmlgen.getxml('select column1, column2 from table_x') from dual;

gives:

<?xml version="1.0"?>
<ROWSET>
 <ROW>
  <COLUMN1>row1</COLUMN1>
  <COLUMN2>1</COLUMN2>
 </ROW>
 <ROW>
  <COLUMN1>row2</COLUMN1>
  <COLUMN2>2</COLUMN2>
 </ROW>
</ROWSET>
How to get:
<?xml version="1.0"?>
<ROWSET>
 <ROW>
  <COL_DTLS>
    <COL_VALUE>row1</COL_VALUE>
  </COL_DTLS>
  <COL_DTLS>
    <COL_VALUE>1</COL_VALUE>
  </COL_DTLS>
 </ROW>
 <ROW>
  <COL_DTLS>
    <COL_VALUE>row2</COL_VALUE>
  </COL_DTLS>
  <COL_DTLS>
    <COL_VALUE>2</COL_VALUE>
  </COL_DTLS>
 </ROW>
</ROWSET>
In summary.

1. how to 'inject' the COL_DTLS tag for each piece of old LINE.
2. how to change each element tag name line to 'COL_VALUE '.

Note that the < Column1 > tag could change your name to any other tag, I have to be able to handle any valid SQL that generates SQL column names and number of items will change

DBMS_XMLGEN can control only the names of ROWSET and ROW tags.
So, if your only entry is a string SQL, then you must postprocess the XML generated, and XSLT can be useful here:

SQL> select xmltransform(
  2    dbms_xmlgen.getxmltype('select column1, column2 from table_x')
  3  , xmltype(
  4  '
  5    
  6    
  7      
  8        
  9      
 10    
 11    
 12      
 13    
 14  '
 15    )
 16  ).extract('/*')
 17  from dual
 18  ;

XMLTRANSFORM(DBMS_XMLGEN.GETXM
--------------------------------------------------------------------------------

  
    
      row1
    
    
      1
    
  
  
    
      row2
    
    
      2
    
  

 

Otherwise, the implementation of PL/SQL:

DECLARE

  ctx   dbms_xmlgen.ctxHandle;
  doc   clob;

  xsl   xmltype := xmltype('
  
  
    
      
    
  
  
    
  
');

  qry   varchar2(2000) := 'select column1, column2 from table_x';

BEGIN

  ctx := dbms_xmlgen.newContext(qry);
  dbms_xmlgen.setXSLT(ctx, xsl);
  doc := dbms_xmlgen.getXML(ctx);
  dbms_xmlgen.closeContext(ctx);

  dbms_output.put_line(doc);

END;
/

Tags: Database

Similar Questions

  • How can I change the default output module in After Effects CS6?

    How can I change the default output module in After Effects CS6? At the moment it is .avi and I do not want to change it to .mov whenever I start a new project. (Windows 8)

    Change--> output Module settings.  being enawed by the beauty and the usefulenss of this Panel...

    Mylenium

  • Need help to change the default output page WebHelp

    Hi all

    I use RoboHelp 10 and try to generate a WebHelp output. I'm unable to change the default value, the destination page. I checked all the relevant discussions in this forum, but I still have the issue.

    I want my default destination as 'introduction' page in the webhelp output. So I point the "introduction.htm' in WebHelp settings by virtue of the"output folder and Start Page"as shown in the below figure and"record and produce ".

    WebHelp Settings.png

    The generated output is always taking me to another topic as shown in the illustration below.

    Landing Page RoboHelp.png

    The URL in the address displayed correctly, but the subject does not change. I need someone to help me solve this problem.

    Thank you!

    Hello

    The name you specify is the start of production, not the topic file that is responsible: the file used to launch help.

    Go to content categories, choose the category and select the 'default'.

    Take a bow

    Willam

  • How to change the default value of MS Paint record - an output to jpg for shortcuts KEYBOARD: Alt-F-A (or S)?

    I've seen a lot of posts on this subject here, but they are all on the use of the mouse and I did not yet find one with an answer to MY specific dilemma.

    I take screenshots and edit photos (Nothing fancy) almost every day. Given that my physical disability in my arms causing me pain and discomfort when I use the mouse, I need to use several shortcuts as humanly possible help reduce the constant pain, I'm still in my right arm using the mouse.

    I *need* to know how to change the default hotkey Alt-F-A (or S) to save it as a JPG file relative to the current default value PNG which I use never, never. If it requires editing the registry, no problem, just point me in the right direction and guide me on how to do it.

    Thank you

    Lee

    LAST UPDATE 09/30/15 @ 16:54:

    The solution to my dilemma can be seen in my other thread (analogue/reprise). It is in case anyone in the future stumbles across this thread with the same problem and needs the answer.

    Since this thread will not be deleted, I would would add the link to the solution in case anyone stumbles across this in the future.

    See my other thread at: [Solution here]

  • How to change the audio output for the metronome

    Hello

    I would like to send the metronome (and speech signals) for monitors to the scene in the ear.

    I understand that I can do this in MainStage using different output for the above titles vs. the rest of the 'Concert '.

    I tried to follow the instructions of the Manual:

    Change the audio output for the sound of the metronome

    1. Choose the MainStage > Preferences > General.
    2. In the section of metronome on the general tab, choose another audio output on the shortcut menu to exit.

    PROBLEM

    1. on the general tab, only the outputs 1-2 are available/selectable (likely, these are also by default for all "Concert")

    2. Why is this process in the manual if it is not executable (without doing something to another additional Set up)?

    3. it's probably among the requirements of setting up more critical even easier for using MainStage with a live band, so why am I having to ask for help at all!

    Rant on (its been a long day)

    Grateful for any help to solve cela. I guess I can send the metronome (such as a click track) and speech signals on the same outputs, which are separated from the rest of the Concert... or should I change the outputs on the other tracks and keep the outputs 1-2 for the metronome marks / voice?

    Thanks in advance for all advice and my apologies for my frustration. JM

    To access the output audio, you need an audio interface with several outputs.

  • Change the default audio device and the recognition of the application

    I'm new to Vista (home premium w/sp2) and I am confused by works the assignment of default device (control_panel-> sounds), specifically the device change with existing applications (running).

    I change frequently between the speakers and the headphones - however, the change of output device is not recognized by running applications, such as iTunes or Firefox and will not be recognized until I have completely quit and restart the application.

    Why?  It is extremely annoying and incoherent other well educated such as Mac OS X platforms.  I would just like to change the default audio output device, on the fly, without the need to restart applications.

    I do something wrong or Vista offers this functionality to the end user?

    Thank you!

    Hello Wyntr,

    Thank you for using the Microsoft answers Forum.

    Currently, the function of switching between audio output devices is carried out manually. To make the selection, you can click the sound icon in the taskbar, then click the button at the bottom of the volume control Mixer. In the properties of the volume, you can click on devices in the upper left corner and select the appropriate device to make it the default for applications open from then on.

    Let us know if this can help, or if you have additional questions on this subject.

    Judd
    Engineer Microsoft Support answers visit our Microsoft answers feedback Forum and let us know what you think.

  • Is it possible to put the speakers as the default output for the sounds of Windows and the headset as default device for music?

    Hello

    Is it possible to have all the sounds through the speakers, including music from WMP and WMP music in my headphones? Headset is USB (but I also have a Jack) and my speakers are with 3 Sockets at the back of my pc.
    Thank you.
    Friend,
    Zoenvisje
     
    Original title: all sounds through loudspeakers and music through headphones

    Hi zoenvisje,

    Thanks for posting your query in the Microsoft Community.

    Want to know if it is possible to play any sound on the computer with the headset. It can be difficult when something that is important to you does not work as expected.

    Method-

    It is not possible to make these changes on the computer.

    You can set a default speakers and use a different music player that supports select the default output as the headset device.

    We know if you need help. We will be happy to help you. We, at tender Microsoft to excellence.

    Thank you.

  • Change the default template

    I do internal documentation and want to change the default styles for the scheme of reagent of HTML5. Should what files I edit so that all new projects use our styles?

    I could be wrong, but I suspect that Willam wanted with the right button of the pod output configuration.

    See you soon... Rick

  • How to change the default alignment of text in the cells in a table on the demand for numbers?

    I'm new to Mac. I own a MacBook pro MF839HN/A and currently using the 3.6.2 release NUMBERS (2577). I want to know if I can change the default alignment of text in the cell in a table of NUMBERS application? Also, when I select all the cells in a table to change their alignment, I can only change the horizontal alignment of the text and not the vertical alignment. To change the vertical alignment of the text in a cell, I have to select them individually. Help me with two questions.

    The only way I know is to create a table that is set up as you like, then save the empty document as a template customized by using the menu item "file > save as template:

  • When I start Firefox, the default email is gmail. I have several gmail accounts. How can I change the default gmail to another gmail account?

    I have 4 gmail accounts (two for me, one for wife and a common email). The default value to "send a link" default settings for my wife's gmail account. I would like to change the default value to our gmail spouse. I need instructions on how to do it.

    Hmm, I think the different built-in options for email link are neutral and used special account would be one that is currently logged on (or if you get a login page, it can show one that was last saved in). This is not what you see?

  • Is there a way to change the default options when receiving the Images on parachuting on a mac?

    Is there a way to change the default options when png or JPEG received on a mac? I can choose between backup to the downloads folder, or open photos. I would like to open in preview instead. Any ideas?

    Problem solved. No apparent reason, the two choices (save downloads and open in photos) presented disappeared and now I have the only option I get is to open the image in preview. No idea how this happened, but my problem is solved.

  • I want to change the default printer for Firefox how can I do this?

    When I choose to print in Firefox it uses my printer copier not my default printer. So how can I change the default printer for Firefox?

    In Firefox 'by default' is the last used printer. If you switch to a different printer, Firefox to remember that a new 'default' - unless you have disabled this setting in all: config. Print.save_print_settings

  • How to change the default printer in Thunderbird

    I have access to several printers that I use in different places. I have to manually change the choice of printer with each e-mail letter I want to print when I change my location when you use thunderbird. I already changed the default printer in my printers folder. All other programs, including Firefox accept the choice of the default printer. How can I get Thunderbird to accept my default without delete all THE OTHER PRINTERS?

    The menu bar, select Tools-Options-Advanced-General
    Select the configuration editor
    Promise to be careful
    Enter the following in the search field: print_printer
    When this line appears, right-click and select reset.

    See if she resumes the new default printer after you restart Thunderbird.

    No menu bar? Press the ALT key.

  • Is it possible to change the default channel strip settings?

    Is it possible to change the default channel strip without having to depend on models?

    For example, I always wish to have:

    • Follow the value Name = 3 lines instead of the default line 1.
    • 'Follow the icons' checkbox deselected
    • Always follow box color
    • Control surface Bars always deselected

    Stuff like that... This apples to any screen that is affected by the Configuration of channel strip window. (View mixer or titles).

    Thank you!

    Is it possible to change the default channel strip without having to depend on models?

    NO.

    But why not use a template? You use a template of this moment anyway, the default value of project. Just change and set the Start Action that you configured

    Fact

    Edgar Rothermich - LogicProGEM.com

    (Author of "Graphically improved manuals")

    http://DingDingMusic.com/manuals/

    "I could receive some form of compensation, financial or otherwise, my recommendation or link."

  • How can I change the default zoom for the new tab only?

    The new tab in Firefox 33 zoom is too high to see all 12 of my thumb nail. I changed it using ctrl - but the next time I opened a new tab, the zoom is 100%. How can I change the default zoom for the new tab only?

    I posted a style rule to shrink the tiles, which allows several of them on the page, but naturally reduces their legibility. You can experiment with the dimensions to find a look that works for you.

    https://userstyles.org/styles/106326/shrink-new-tab-thumbnails

    I use the Stylish extension to experiment because of its preview function that allows me to see the effect quickly. You can install it from the site of modules, then after restart of Firefox while searching for his "S" icon in the toolbar to manage Styles so you can edit and experiment.

    https://addons.Mozilla.org/firefox/addon/stylish/

Maybe you are looking for