Returning query results in XML format
Besides using custom tag library, does anyone know any methods or techniques that i can retrive the query results from database in XML format. for example, i have a table named student in database like this:
StudentNo Name Gender Degree
123 Tony male B.Comp.Sci.
456 Tom male B.Fiance
343 Mary female B.Accountingso, if i have query select * from table student, i would get someting like the following:
<row>
<studentNo>123</studentNo>
<name>Tony</name>
<Gender>male</Gender>
<Degree>B.Comp.Sci</Degree>
</row>
<row>
<studentNo>456</studentNo>
<name>Tom</name>
<Gender>male</Gender>
<Degree>B.Finace</Degree>
</row>
The reason i am asking for this is i need query results returned in XML format, so i can wrap XSLT tag around, and apply for HTML, WML, and XHTML template resprectively so i can display them on different terminals. any help is appreciated.
I have this method in a ResultSetMapper class:
* Return result sets as an XML stream, with root tag named
* "results", one "result" tag per row, and "result" child tag
* names equal to the column name
* @param query result set
* @param list of column names to include in the result map
* @throws SQLException if the query fails
* @throws JDOMException if the XML stream creation fails
public static final Document toJDOM(ResultSet rs, List wantedColumnNames)
throws SQLException, JDOMException
Element rows = new Element("results");
int numWantedColumns = wantedColumnNames.size();
while (rs.next())
Element row = new Element("result");
for (int i = 0; i < numWantedColumns; ++i)
String columnName = (String)wantedColumnNames.get(i);
Object value = rs.getObject(columnName);
row.addContent(new Element(columnName).setText(value.toString()));
rows.addContent(row);
return new Document(rows);
}It uses JDOM from www.jdom.org. - MOD
Similar Messages
-
Output query result in XML format
folks:
could anybody provide more information
about how to generate query result in
xml format? looks like DBXML is for demo only
and i have heard that PLSQL XML parser is the way to go; so far i have not found
a sample yet on how to actually
do the XML generation; if you know more
about it, please let me know; thanks in
advance.
BillHere are some sample apps that might interest you:
[list]
[*][url [URL=http://technet.oracle.com/tech/xml/xsql_servlet/index2.htm?Code&files/ffhome.html]The]http://technet.oracle.com/tech/xml/xsql_servlet/index2.htm?Code&files/ffhome.html]The XML Flight Finder
[*][url [URL=http://technet.oracle.com/sample_code/tech/xml/xmlb2b/doc/xb2bhome.html]B2B]http://technet.oracle.com/sample_code/tech/xml/xmlb2b/doc/xb2bhome.html]B2B with XML
[list]
Enjoy,
-rh -
How to: SELECT statement returns the result in XML format.
That's it... I want to execute a query that returns all rowset in XML format. How can I do it?
Using Oracle 8.0 and up.
Tnx.FOR XML is a proprietary Microsoft Hack... It is not supported by Oracle in any release. Oracle 9.2.x includes the SQLXML operators, which are part of the SQL:2003 standard and are the agreed upon (Mircosoft, IBM, Oracle etc) way of generating XML from relational data....
See http://download-west.oracle.com/docs/cd/B12037_01/appdev.101/b10790/xdb03usg.htm#sthref251 -
How a SELECT statement can return the results in XML format
That's it... I want to execute a query that returns all rowset in XML format. How can I do it?
I have Oracle 9i
Thanks
Jaime9i, or 9iR2 ?. If 9i I would recommend upgrading to 9iR2 and then using the SQL/XML operators.
-
Saving the query result in XML format
Hi All,
I have a requirement to save the result of a query in XML format on the application server. Can we do this?
Best Rgds,
James.You can explore the possibility of the execution of query with XMLA:
Official documentation
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1d71d190-0201-0010-239a-8b96516bf372
and a good Blog
/people/prakash.darji/blog/2006/09/04/work-with-xmla-web-service-for-bi-data-in-external-applications
The result will be an SOAP message (XML) but also the request could be a SOAP message you can investigate if simulate the request by BW client or server.
Regards,
Sergio -
Ps query results to xml using xml link function registry
In People tools version 8.46 we need something like where the ps query result output is in the form of XML so that it can be used for external system. The catch I cannot use webservices. It is something like opening peoplesoft queires form excel using hyperlink but in this case we need xml. I looked at David Vandiver's Excel XML libraries which open the data in excel but is there something where the hyperlink output is xml using xml link function registry. I have capatured the data in rowset and now need to create mime type of xml to write the data
thanks in advance
vinnIf I understand correctly, you want to use something like Microsoft Excel's web queries to get data from a PeopleSoft query in XML format. I have never done this before, but if I were to implement this, here is what I would do in PT 8.46:
1. Create an unstructured message in app designer.
2. Create a user that only has access to the queries you want to expose to Excel
3. Write synchronous message handler PeopleCode to call SwitchUser to switch to a specific query user rather than the generic integration broker user and execute a query, returning the results in XML (see [Query.RunToRowsest|http://download.oracle.com/docs/cd/E13292_01/pt849pbr0/eng/psbooks/tpcr/htm/tpcr31.htm#d0e113933] for an example).
4. Call the message through IB using the HTTP GET URL format as defined in PeopleBooks: [http://download.oracle.com/docs/cd/E13292_01/pt849pbr0/eng/psbooks/tibr/book.htm?File=tibr/htm/tibr33.htm#H4026|http://download.oracle.com/docs/cd/E13292_01/pt849pbr0/eng/psbooks/tibr/book.htm?File=tibr/htm/tibr33.htm#H4026]. -
Broadcasting the precalculated query results in web format
Hi Experts,
We have a requirement where we need to broadcast the precalculated query results in web format, we know that we can do this through workbook, but we want to do it in web format to avoid the limitations of the workbook like number of rows in workbook limited to 65000 etc.,
We are using 3.x environment,
please suggest that is this functionality can be achievable, if yes how?
Thanks in advance,
-VinayHi All, this problem was resolved.
Thanks,
vinay -
How to return query result in procedure
Hi all,
Can anyone tell me how to return query result in pl/slq procedure using out .
thank you
regards
P PrakashProcedure for sys_refcursor:
create or replace procedure ptest(c out sys_refcursor) is
begin
open c for select * from dual;
end;Procedure for collections(although sys.ODCIVarchar2List is varray, same example you can use with "table of")
create or replace procedure ptest2(c out sys.odcivarchar2list) is
begin
select dummy
bulk collect into c
from dual;
end;Example:
declare
c sys_refcursor;
v varchar2(100);
vt sys.odcivarchar2list;
begin
ptest(c);
fetch c into v;
dbms_output.put_line('1.Cursor data: '||v);
ptest2(vt);
dbms_output.put_line('2.Collection data: '||vt(1));
end;Regards,
Sayan M. -
How to send SQL query results to XML ?
Hey Guys, I am querying a DB with huge amount of traffic. A user select a particular lot and then details of the lot will be displayed in the following page. My concern here is that it takes really LONG to retrieve back the results coz it has to requiry in the following JSP page.
I was told to use XML to retrieve the dataset and store it. Hence, in the following query it will re-query only from the recordsets in the XML file (...Logically, should be faster rite ? ). Hence, how do parse my recordsets retrieved from the SQL query to an XML file ?
Any sort of suggestion , help, reference would be deeply appreciated ..Thanks !<HTML>
<BODY>
<H1>Manufacturing Summary beta </H1><BR>
<%@ page import="java.sql.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.text.*" %>
<jsp:include page="/index.html" flush="true"/>
<P><B>Returned result<B><BR>
<B>Query String :</B><%=request.getParameter("date") %>
<TABLE BORDER=1 cellpadding=0 cellspacing=0>
<%!
static double roundDouble(double toBeRounded, int fractionDigits)
NumberFormat format = NumberFormat.getInstance();
format.setMaximumFractionDigits(fractionDigits);
String tempDouble = format.format(toBeRounded);
return Double.parseDouble(tempDouble);
%>
<%
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@klmomnidb:1521:
OMNIDB","omni","omni");
Statement stmt = null;
ResultSet rset = null;
String S_date = new String();
String temp = new String();
String lot_id = new String();
String result = new String();
String SQL_String = new String();
double yield;
int bad_cnt;
S_date = request.getParameter("date");
lot_id = request.getParameter("lot_id");
temp = request.getParameter("TST_TEMP");
SQL_String = "SELECT LOT_ID, FLOW_ID, TST_TEMP, MODE_COD, RTST_COD, PART_CNT, GO
OD_CNT, OPER_NAM, JOB_REV, PROC_ID, START_T, FACIL_ID, TSTR_TYP, NODE_NAM FROM L
OT where START_T > TO_DATE('"+ S_date + "','MM/DD/YYYY') AND TST_TEMP <='" + tem
p+"' order by START_T";
out.println(SQL_String);
stmt = conn.createStatement();
rset = stmt.executeQuery (SQL_String);
out.println("<TR>");
out.println("<TD> Select Lot(s)</TD>");
out.println("<TD>Flow </TD>");
out.println("<TD>Temp </TD>");
out.println("<TD>Test Mode </TD>");
out.println("<TD>Retest</TD>");
out.println("<TD>Total </TD>");
out.println("<TD>Good</TD>");
out.println("<TD>Bad</TD>");
out.println("<TD>Yield </TD>");
out.println("<TD>UserID</TD>");
out.println("<TD>Program</TD>");
out.println("<TD>Mask</TD>");
out.println("<TD>Start Time </TD>");
out.println("<TD>Loc </TD>");
out.println("<TD>Tester</TD>");
out.println("<TD>System </TD>");
out.println("</TR>");
if (! rset.next()) {
result ="No records found matching seach criteria.";
while (rset.next()) {
bad_cnt = Integer.parseInt(rset.getString(6)) - Integer.parseInt(rset.getString(
7));
yield = (Double.parseDouble(rset.getString(7)) / Double.parseDouble(rset.getStri
ng(6))) * 100;
result= "<TR>";
result = result + "<TD><a href=coolpage.jsp?LOT_ID=" + rset.getString(1)+ ">" +
rset.getString(1) + "</A></TD>";
result = result + "<TD>" + rset.getString(2) + "</TD>";
result = result + "<TD>" + rset.getString(3) + "</TD>";
result = result + "<TD>" + rset.getString(4) + "</TD>";
result = result + "<TD>" + rset.getString(5) + "</TD>";
result = result + "<TD>" + rset.getString(6) + "</TD>";
result = result + "<TD>" + rset.getString(7) + "</TD>";
result = result + "<TD>" + bad_cnt + "</TD>";
result = result + "<TD>" + roundDouble(yield,2) + "% </TD>";
result = result + "<TD>" + rset.getString(8) + "</TD>";
result = result + "<TD>" + rset.getString(9) + "</TD>";
result = result + "<TD>" + rset.getString(10) + "</TD>";
result = result + "<TD>" + rset.getString(11) + "</TD>";
result = result + "<TD>" + rset.getString(12) + "</TD>";
result = result + "<TD>" + rset.getString(13) + "</TD>";
result = result + "<TD>" + rset.getString(14) + "</TD>";
result = result + "</TR>"; %>
<%=result%>
<% }
rset.close();
stmt.close();
conn.close();
%>
<%=result%>
</TABLE>
</BODY>
</HTML> -
SQL Developer 4.0 EA3. query result in export format problem
Query output in export format (insert, csv, xml,...) is not working in 4.0 EA3.
Query executed as script (F5) does not display anything:
select /*insert*/ * from dual;
SQL Developer 3 displays the result correctly:
REM INSERTING into dual
SET DEFINE OFF;
Insert into "dual" (DUMMY) values ('X');
About
Oracle SQL Developer 4.0.0.13
Version 4.0.0.13
Build MAIN-13.30
IDE Version: 12.1.3.0.41.131007.2031
Product ID: oracle.sqldeveloper
Product Version: 12.2.0.13.30
Version
Component Version
========= =======
Oracle IDE 4.0.0.13.30
Java(TM) Platform 1.7.0_07
Versioning Support 4.0.0.13.30That's been fixed for the next release.
-
Need the output of a query in given XML format
I have a table as
create table t_cases (case_id number, pros_seq number, case_lname varchar2(100),
day_phone number, night_phone number, intl_phone number);
where case_id and pros_seq is the compound primary key.
The insert script to insert the data in the table is
insert into t_cases values(1, 1, 'test', 12, 23, 34);
insert into t_cases values(1, 2, 'test', 56, 67, 78);
commit;
Now from this table I need to query and fetch the data in the following xml format.
<case REPEATINGTYPE="PageList">
<rowdata REPEATINGINDEX="1">
<caseid>1</caseid>
<prosseq>1</prosseq>
<PhoneNumbers REPEATINGTYPE="PageList">
<rowdata REPEATINGINDEX="1">
<CountryCode>12</CountryCode>
<Type>Day</Type>
</rowdata>
<rowdata REPEATINGINDEX="2">
<CountryCode>23</CountryCode>
<Type>Night</Type>
</rowdata>
<rowdata REPEATINGINDEX="3">
<CountryCode>34</CountryCode>
<Type>International</Type>
</rowdata>
</PhoneNumbers>
</rowdata>
<rowdata REPEATINGINDEX="2">
<caseid>1</caseid>
<prosseq>2</prosseq>
<PhoneNumbers REPEATINGTYPE="PageList">
<rowdata REPEATINGINDEX="1">
<CountryCode>56</CountryCode>
<Type>Day</Type>
</rowdata>
<rowdata REPEATINGINDEX="2">
<CountryCode>67</CountryCode>
<Type>Night</Type>
</rowdata>
<rowdata REPEATINGINDEX="3">
<CountryCode>78</CountryCode>
<Type>International</Type>
</rowdata>
</PhoneNumbers>
</rowdata>
</case>
Please let me know how to do this.Like this...
select XMLELEMENT( "case", XMLATTRIBUTES ('PageList' as "RepeatingType")
,xmlagg(
xmlelement("rowdata", xmlattributes(pros_seq as "RepeatingIndex")
,xmlelement("caseid", case_id)
,xmlelement("prosseq", pros_seq)
,xmlelement("PhoneNumbers", xmlattributes('PageList' as "RepeatingType")
,xmlelement("rowdata", xmlattributes(1 as "RepeatingIndex")
,xmlelement("CountryCode", day_phone)
,xmlelement("Type", 'Day')
,xmlelement("rowdata", xmlattributes(2 as "RepeatingIndex")
,xmlelement("CountryCode", night_phone)
,xmlelement("Type", 'Night')
,xmlelement("rowdata", xmlattributes(3 as "RepeatingIndex")
,xmlelement("CountryCode", intl_phone)
,xmlelement("Type", 'International')
as x
from t_cases -
Need output of a query in given xml format.
I have a table as
create table t_cases (case_id number, pros_seq number, case_lname varchar2(100),
day_phone number, night_phone number, intl_phone number);
where case_id and pros_seq is the compound primary key.
The insert script to insert the data in the table is
insert into t_cases values(1, 1, 'test', 12, 23, 34);
insert into t_cases values(1, 2, 'test', 56, 67, 78);
commit;
Now from this table I need to query and fetch the data in the following xml format.
<case REPEATINGTYPE="PageList">
<rowdata REPEATINGINDEX="1">
<caseid>1</caseid>
<prosseq>1</prosseq>
<PhoneNumbers REPEATINGTYPE="PageList">
<rowdata REPEATINGINDEX="1">
<CountryCode>12</CountryCode>
<Type>Day</Type>
</rowdata>
<rowdata REPEATINGINDEX="2">
<CountryCode>23</CountryCode>
<Type>Night</Type>
</rowdata>
<rowdata REPEATINGINDEX="3">
<CountryCode>34</CountryCode>
<Type>International</Type>
</rowdata>
</PhoneNumbers>
</rowdata>
<rowdata REPEATINGINDEX="2">
<caseid>1</caseid>
<prosseq>2</prosseq>
<PhoneNumbers REPEATINGTYPE="PageList">
<rowdata REPEATINGINDEX="1">
<CountryCode>56</CountryCode>
<Type>Day</Type>
</rowdata>
<rowdata REPEATINGINDEX="2">
<CountryCode>67</CountryCode>
<Type>Night</Type>
</rowdata>
<rowdata REPEATINGINDEX="3">
<CountryCode>78</CountryCode>
<Type>International</Type>
</rowdata>
</PhoneNumbers>
</rowdata>
</case>
Please let me know how to do this.Like this...
select XMLELEMENT( "case", XMLATTRIBUTES ('PageList' as "RepeatingType")
,xmlagg(
xmlelement("rowdata", xmlattributes(pros_seq as "RepeatingIndex")
,xmlelement("caseid", case_id)
,xmlelement("prosseq", pros_seq)
,xmlelement("PhoneNumbers", xmlattributes('PageList' as "RepeatingType")
,xmlelement("rowdata", xmlattributes(1 as "RepeatingIndex")
,xmlelement("CountryCode", day_phone)
,xmlelement("Type", 'Day')
,xmlelement("rowdata", xmlattributes(2 as "RepeatingIndex")
,xmlelement("CountryCode", night_phone)
,xmlelement("Type", 'Night')
,xmlelement("rowdata", xmlattributes(3 as "RepeatingIndex")
,xmlelement("CountryCode", intl_phone)
,xmlelement("Type", 'International')
as x
from t_cases -
Download BW Query results in HTML format
On a daily basis, I need to get BW query results exported to an HTML extract file on the BW server. The HTML file will then be transferred to a Windows server for use in a dashboard view by a third party developed portal. The query has an input variable for period.
What is the best/simplest method for scheduling an existing BW query to run on a daily basis to produce an HTML extract / download file to the BW server file system?
We are currently on BW 7.01 SP6. We just completed a technical upgrade from BW3.5, but did not do a functional upgrade.
I have read through many postings but have been unable to find a solution. I have reviewed RSCRM_BAPI u2013 no html format.
Any help would be greatly appreciated.
Thanks,
Mark NortonHello Mark...
Amer is right. You can create a broadcast setting to daily sends your
query as MHTML format.
You can send to your e-mail but there is a possibility to save on KM and CM repository.
There is a little explanation on the link below:
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/5c6b686a-0901-0010-8aab-c4d0e5a093a7?quicklink=index&overridelayout=true
To create a broadcast setting, open the query via Query Designer.
Click "Query" -> "Publish" -> "BEx Broadcaster"
While you are creating the broadcast, there is a "Output Format" option.
There is MHTML.
I hope you find this information useful.
Thanks
Edward -
Row query results to column format
I have a table as follows:
DT | SN | Type | Value
1/1/15 1:15 | 1 | HID | 123
1/1/15 1:15 | 1 | VAL | 456
1/2/15 1:15 | 1 | HID | 123
1/2/15 1:15 | 1 | VAL | 111
1/4/15 1:15 | 2 | HID | 222
1/4/15 1:15 | 2 | VAL | 233
1/5/15 1:15 | 3 | HID | 333
1/5/15 1:15 | 3 | VAL | 344
How to I construct a query in the below format...
DT | SN | HID | VAL
1/1/15 1:15 | 1 | 123 | 456
1/2/15 1:15 | 1 | 123 | 111
1/4/15 1:15 | 2 | 222 | 233
1/5/15 1:15 | 3 | 333 | 344Hi engrforever,
Use a PIVOT to do it. Modified the date values here:
Create TABLE #TEMP1
(DT datetime NULL,
SN int NULL,
[Type] varchar(12) NULL,
Value int NULL
INSERT INTO #temp1(DT, SN,Type,Value) VALUES (GETDATE()-4,1,'HID',123),
(GETDATE()-4,1,'VAL',456),
(GETDATE()-3,1,'HID',123),
(GETDATE()-3,1,'VAL',111),
(GETDATE()-2,1,'HID',222),
(GETDATE()-2,1,'VAL',233)
SELECT * FROM
(SELECT DT,SN, TYPE, Value FROM #temp1) DT
PIVOT
( SUM (VALUE)
FOR TYPE IN ([HID],[VAL])
) PT
DROP TABLE #TEMP1 -
Hi!
I need to do the following thing: after making a query in a database like:
SELECT * FROM table WHERE column = 'value'
Notice that the query always gets information from only one table.
I need to get the results of the query and put them in a text file, so that another application will receive the text file and update its own database using the information in the file. I think XML is a good format for doing that, so the file would be something like this:
<List>
<Object>
<column name>value</column name>
<another column name>value</another column name>
</Object>
</List>
Does anyone know an easy way to do something like that? The file format doen't need to be XML, I just want a format that will make it easy to get the information. The most important is that I get a generic code that works for any table, and that won't need to be changed if the database changes.
Thanks in advance!Many databases have dump and restore utilities that are already written, and often at least as fast as anything you could write yourself. Many of them give you a great deal of control on the selection of what is to be dumped, and some of them output in a format that may be suitable (with a little massaging) for import into another database.
For example, for MySQL:
http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html
Maybe you are looking for
-
Shared printer doesn't appear on other Macs
I've had a Brother HL 4050 color laser printer for several months. It's worked great on my home network. I connected its Ethernet to my Time Capsule, and my wireless machines could print to it with no problems. The only quirk has been that the printe
-
Physycal Standby archive log gap....
Archive log gap caused... The reason being before the logs can be shipped to standby location where deleted by rman backup... So restored the archives on primary database site back again... These old logs from the gap are not getting shipped to the s
-
OS X reinstall - partial time machine restore?
I'm thinking of wiping my drive clean and reinstall Leopard to get rid of all the junk and hopefully resolve some other issues. I have a Time Machine backup of everything, but given my purpose for reformatting my drive I obviously don't want to do a
-
Prerequisites for creating returns PO
Hi, I need to know what are the prerequisites for creating a returns PO. Are there anu customising setting or Master data to be changed ? Regards, SR
-
Separate date elements(yyyy-mm-dd)
i want to get Date from database with the format yyyy-mm-dd then how am i going to separate its elements(String year,String month,String day)?it can be done with the string operations but i want to ask if there is any java functions about it like for