Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I save PL/SQL output (clob) as an XML file?
    primarykey
    data
    text
    <p>I feel quite stupid at this stage as this doesn't seem like a task i should be battling with, but after little sleep and with a 1000 thoughts running through my mind I think i'm the frog in the pot now with the tunnel-vision-virus clouding the solution. Here goes:</p> <p>I have a query in PL/SQL that selects data out of a few tables into an XML format (1 row, 1 column being a CLOB type) using DBMS_XMLGEN.getxml. This works perfectly.</p> <p>My problem comes in returning this XML output to C#, and asking the user where he'd like to save this output as an output.xml file, on his personal pc.</p> <p>I'm using ASP.net with JQuery (AJAX), thus posting to an .aspx page when a link is clicked and using the returned data (the xml coming from the query in this instance) to save. Using an OLEDB command with an OLEDB datareader doesn't seem to be the correct way...</p> <p>What is the best way of doing this? I haven't worked a lot with serialization within .net, but i assume this is the best way (according to the research I've done)? Does anyone have an example of how this can be done in my situation? </p> <p>My thoughts are basically creating this output / file in memory, asking the user where he wants to save it, saving it as a .xml file and clearing the memory.</p> <p>UPDATE: Ok I managed to create an XMLDocument which easily just accepts the xml output from my query. How could I go about getting input from the user on where to save this file on his pc?</p> <p>My code so far:</p> <p>Javascript : </p> <pre><code>function XML_ExportAppRestrictions() { try { var data = {"action": "exportAppRestrictions"}; var returned = AjaxLoad('Modules/Common/Common.aspx', null, data, null, null, false); if (returned.toString().toUpperCase().substring(0, 5) == "ERROR") { return; } else { // should the file be saved here or in my aspx page using xmldoc.save? // Using xmldoc.save will only be able to save the file on the server yes? } } catch (ex) { alert(ex.Message); } } </code></pre> <p>ASP:</p> <pre><code>if (Request["action"] == "exportAppRestrictions") { // Create and open DB connection conn.ConnectionString = SG_Common.CommonClass.NetRegUDL; common.OpenDBConnection(ref conn); // Create command and set SQL statement cmd.Connection = conn; cmd.CommandType = System.Data.CommandType.Text; // select text was removed below due to it's length cmd.CommandText = "select x as AppRestrictions from dual"; rd = cmd.ExecuteReader(); if (rd.HasRows) { if (rd.Read()) { str = rd["AppRestrictions"].ToString(); } } rd.Close(); System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument(); xmldoc.InnerXml = str; xmldoc.Save("c:\\xmltest.xml"); goto Done; } // Done runs in a seperate try/catch statement and only returns data to the calling js function. Done: Response.Write(str); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload