SQL/XML ... beginner's question ...
Hi Everyone,
I would like to output to XML and Oracle seems to have all the tools that I need, starting with XMLElement. However, I am having some trouble getting off the ground here.
I wanted to test with a small table thus ...
SELECT XMLElement("PCL",PCL) AS "RESULT"
FROM DWH_T_TM_KONSTANTE
... and although the correct number of rows is returned there was no data displayed (in SQL*Plus).
I then tried the following ...
SELECT XMLElement("mydate",SYSDATE) AS "RESULT"
FROM DUAL
... but also received one row returned but no data / no XML.
So my question here is what am I doing wrong?
There were no error messages, just no data displayed.
Do I maybe need to activate 'XML' on our server? We are using Oracle 10g, release 10.2.0.3.0.
I am sure that it is a simple thing and so would be grateful for any help that you can give.
Regards,
Alan Searle
Cologne, Germany
Just a quick supplement to my question ...
I tried ...
SELECT XMLCOMMENT('mycomment') AS "XMLCOMMENT"
FROM dual;
... and got a correct, parsed result ...
XMLCOMMENT
<!--mycomment-->
So XML functionality must be working.
However, XMLELEMENT somehow seems to be correctly selecting the data (correct number of rows returned) but is not displaying any output.
This must be such a simple thing but I can't work out what I am doing wrong.
Regards,
Alan
Similar Messages
-
Very basic SQL/XML question
I'm using the following environment:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
However, I don't think my environment is the issue.
I'm trying to get output which looks like this from a simple table:
<MAXDOMAIN action="S">
<DOMAINID key="true">domainid_data</DOMAINID>
<SYNONYMDOMAIN type="relationship" action="AU" >
<VALUE key="true">value_data</VALUE>
<MAXVALUE>maxvalue_data</MAXVALUE>
<DESCRIPTION>description_data</DESCRIPTION>
<DEFAULTS>defaults_data</DEFAULTS>
</SYNONYMDOMAIN>
</MAXDOMAIN>The table looks like this
Name Null Type
DOMAINID NOT NULL VARCHAR2(30)
DESCRIPTION VARCHAR2(50)
DOMAINTYPE VARCHAR2(5)
MAXTYPE VARCHAR2(5)
LENGTH VARCHAR2(5) The real question is how do I get an element with attributes to also have content.
<DOMAINID key="true">domainid_data</DOMAINID>and
<VALUE key="true">value_data</VALUE>I'm not sure if I'm syntactically challenged or just not using the correct tags.
If I try to just generate the first two tags, forgetting the following nesting, I'm OK, as long as I don't try to assign attributes to the DOMAINID tag:
SELECT XMLELEMENT
("MAXDOMAIN",XMLATTRIBUTES('S' AS "action"),XMLELEMENT(NAME DOMAINID, "DOMAINID")
AS "RESULT"
FROM FAC_MAXDOMAIN;This works and is pretty trivial.
<MAXDOMAIN action="S"><DOMAINID>AIRFLOWTYPE</DOMAINID></MAXDOMAIN>
etc, etc...However, this:
SELECT XMLELEMENT
("MAXDOMAIN",XMLATTRIBUTES('S' AS "action"),XMLELEMENT(NAME DOMAINID, "DOMAINID",XMLATTRIBUTES('true' AS "key"))
AS "RESULT"
FROM FAC_MAXDOMAIN;Yields an ORA-00907: missing right parenthesis error.
Any ideas? maybe a good primer on SQL/XML might be the best solution...
TIA,
PaoloVery nice for a first post in terms of data included and formatting.
It took me a few minutes to see it, but the simple answer is you are putting the XMLAttributes in the wrong location. See the XMLElement spec at http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions220.htm#SQLRF06168 that shows XMLAttributes comes between the identifier and value. So that means you should have written it as
Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.6.0
SQL> WITH FAC_MAXDOMAIN AS
2 (SELECT 'domainid_data' domainid, 'dscr' description,
3 'type' domaintype, '10' maxtype, '5' length
4 FROM dual)
5 -- Using WITH so didn't have to create your table locally
6 SELECT XMLELEMENT("MAXDOMAIN",
7 XMLATTRIBUTES('S' AS "action"),
8 XMLELEMENT(NAME DOMAINID, XMLATTRIBUTES('true' AS "key"), "DOMAINID")
9 )
10 AS "RESULT"
11 FROM FAC_MAXDOMAIN;
RESULT
<MAXDOMAIN action="S"><DOMAINID key="true">domainid_data</DOMAINID></MAXDOMAIN> -
PL/SQL + XML with Excel report format?
Dear all,
I am a new beginner in XML Publisher. For the EBS11i, I can use PL/SQL with http scripts to generate excel report format.
The following code will include in store procedure:
>
begin
owa_util.mime_header(ccontent_type => 'application/vnd.ms-excel');
htp.htmlopen;
htp.headopen;
htp.print( '<STYLE>' );
htp.print( '<!--'||
'.xl24' ||
'{mso-style-parent:style0;' ||
'mso-number-format:"\@";}' ||
'.xl41' ||
'{mso-style-parent:style0;' ||
'mso-NUMBER-format:"\#\,\#\#0\.000";}' ||
'.xl42' ||
'{mso-style-parent:style0;' ||
'mso-NUMBER-format:"\#\,\#\#0\.00";}' ||
'.xl45' ||
'{mso-style-parent:style0;' ||
'mso-NUMBER-format:"\#\,\#\#0";}' ||
'-->' );
htp.print( '</STYLE>' );
htp.headclose;
htp.bodyopen;
htp.para;
htp.strong( '<U>' || 'Sample Report Name'|| '</U>');
htp.para;
htp.tablerowopen;
htp.tabledata('<DIV align="left">' || rec_main2.vendor_name || '</DIV>',cattributes => ' class="xl24" width="190"');
htp.tablerowclose
>
How can I do that in R12?
Please advice.We currently do not support SQL aliasing of directories. This
is causing your errors.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
Frank Hubeny (guest) wrote:
: I think I got past this point by first creating a directory
: under sys and then granting read privileges to owner of the
: domsample procedure (in my case the this user is called "xml").
: create directory xml as 'e:\web\xml';
: grant read on directory xml to xml;
: Then the call becomes (I think)
: exec domsample ('XML','family.xml','test.err')
: However, I am getting the following error:
: ERROR at line 1:
: ORA-20100: Error occurred while parsing: XML/err.log
: ORA-06512: at "XML.XMLPARSER", line 43
: ORA-06512: at "XML.XMLPARSER", line 120
: ORA-06512: at "XML.DOMSAMPLE", line 80
: ORA-06512: at line 1
: The readme says "It is necessary for the user running
: this sample to have been granted the appropriate security
: priveleges to read and write from a file on the file
: system." I am not sure what the "write" grant would be.
: And so I also set utl_file_dir so that it pointed to
: the directory. But somehow I don't think that utl_file is
: needed in this context. In any case, it appears I cannot write
: to the err.log file or find it.
: Brad Douglass (guest) wrote:
: : I'm receiving the following error when I use the domsample
: : procedure supplied with the PL/SQL XML parser:
: : SQL> exec domsample('e:\web\xml','test.xml','test.err');
: : begin domsample('e:\web\xml','test.xml','test.err'); end;
: : ERROR at line 1:
: : ORA-20101: Error occurred while accessing a file or URL:
: unknown
: : protocol: file
: : ORA-06512: at "XML.XMLPARSER", line 46
: : ORA-06512: at "XML.XMLPARSER", line 164
: : ORA-06512: at "XML.DOMSAMPLE", line 77
: : ORA-06512: at line 1
: : UTL_FILE doesn't have any problems with the file.
: : Any ideas?
null -
Error while running PL/SQL XML Parser Samples
every time try to run the PL/SQL XML Parser Sample program i get this error no file or directory, though the file and dir exists, i have the permissions setup as in readme.txt do i need to do any chnages to init.ora,
pls advice
Thanks,
SQL> exec test
begin test; end;
ERROR at line 1:
ORA-20100: Error occurred while parsing: No such file or directory
ORA-06512: at "SCOTT.XMLPARSER", line 22
ORA-06512: at "SCOTT.XMLPARSER", line 69
ORA-06512: at "SCOTT.TEST", line 13
ORA-06512: at line 1Which examples in particular? Thanks.
-
How do I create an undeclared namespace node with sql/xml?
I have to interact with a .NET web service that is expecting to have an xml node with an undeclared namespace, i.e. <address xmlns=""> I figured that I could create this by using XMLATTRIBUTES ( '' AS "xmlns") but a null attribute will not be added to the attribute listing. This works fine for other xmlns entries that contain values. Without this undeclared namespace node, the web service reports an Internal SOAP failure message, so I have to include it. Do I have to resort to manually injecting this null attribute via DOM after I produce the xml? I'm using SQL/XML query generate the xml as a view which gives me the entire packet for this document/literal web service OTHER THAN this missing undeclared namespace element.
Any tips/suggestions would be helpful! Thanks a bunch, and have a Happy Holiday Season.
EricYou can use UTL_RAW package.
First, convert string to raw with UTL_RAW.CAST_TO_RAW, then using UTL_RAW.CONVERT to convert raw to utf-8 and finally UTL_RAW.CAST_TO_VARCHAR to get utf-8 string.
Regards -
?xml version = '1.0' encoding = 'ASCII'? pl/sql xml parser
When ever I parse a document which has the
<?xml version = '1.0' encoding = 'ASCII'?> tag as the first line hangs the pl/sql xml parser . If I remove the "encoding = 'ASCII'" from the file everything works fine ! What is the problem ?
version 8.1.6 / plsql parser v2 / hpux 11x
Here is the input file
<?xml version = '1.0' encoding = 'ASCII'?>
!--- This is a comment -->
<person>
<employee>
<lastname>GHANTASALA</lastname>
<firstname>SREE</firstname>
<age>32</age>
</employee>
<employee>
<lastname>TAMATAM</lastname>
<firstname>SATISH</firstname>
<age>30</age>
</employee>
</person>
Here is my program
declare
p xmlparser.parser;
doc xmldom.DOMDocument;
dir varchar2(100) := '/apps/oracle/drugstore';
errfile varchar2(30) := 'err.txt' ;
inpfile varchar2(30) := 'person.xml';
nl xmldom.DOMNodeList;
len number;
n xmldom.DOMNode;
new_node xmldom.DOMNode;
node_name varchar2(100);
node_value varchar2(100);
begin
-- new parser
p := xmlparser.newParser;
-- Set some characteristics
xmlparser.setValidationMode(p, FALSE);
xmlparser.setErrorLog(p, dir| |'/'| | errfile );
xmlparser.setBaseDir(p, dir);
-- parse input file
xmlparser.parse(p, dir| |'/'| |inpfile);
-- get document
doc := xmlparser.getDocument(p);
-- get all elements
nl := xmldom.getElementsByTagName(doc, '*');
len := xmldom.getLength(nl);
dbms_output.put_line('Length='| |len);
-- loop through elements
for i in 0..len-1 loop
n := xmldom.item(nl, i);
node_name := xmldom.getNodeName(n);
-- get the text node associated with the element node
n := xmldom.getFirstChild(n);
if xmldom.getNodeType(n) = xmldom.TEXT_NODE then
node_value := xmldom.getNodeValue(n);
if node_name='lastname' then
dbms_output.put_line('The value you are looking for is -->:'| |node_value);
if node_value = 'GHANTASALA' then
xmldom.setNodeValue(n,'TEST2');
end if;
end if;
end if;
end loop;
new_node := xmldom.makeNode(doc);
xmldom.writeToFile(new_node, dir | |'/'| |'mod.xml');
end ;
nullThe encoding header is actually generated by
by the following piece of code in my pl/sql program .
new_node := xmldom.makeNode(doc);
xmldom.writeToFile(new_node, dir | |'/'| |'mod.xml');
Since this is a document created by the pl/sql parser, I assume there is some meaning to it !
Also why is it hanging ? PL/sql parser should tell me that it is not a valid string ! -
i've downloaded the Pl/SQL XML parser demo - xslsample / domsample - followed the guide , etc but I'm getting ....
BEGIN xslsample ('/export/home/oracle/plmx/sample','family.xml','iden.xsl','family.out','errors.txt'); END;
ERROR at line 1:
ORA-29516: Aurora assertion failure: Assertion failure at eox.c:187
Uncaught exception Root of all Java exceptions:
ORA-06512: at "PLMX.XMLPARSERCOVER", line 0
ORA-06512: at "PLMX.XMLPARSER", line 57
ORA-06512: at "PLMX.XSLSAMPLE", line 28
ORA-06512: at line 1
anybody seen this ??There is no such limit on our Parser for PL/SQL. Could you
perhaps be using the PLXML Utilities? If you are you might try
our PL/SQL Parser instead.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
Premal Mehta (guest) wrote:
: Hi
: I am using PL/SQL XML Parser to add XML data in database. I
: am having trouble when using file sixe greater than 500KB?
: What is the alternative? Can I do something to process
larger
: files?
: Please Help, this is quite urgent.
: Hoping for help,
: Premal.
null -
Hi All,
I'm new to XMLPublisher so i'll try to explain the best i can the problem i'm having creating a Data Model for my report.
I'm using Database XE and have installed XMLPublisher, as XE is extremely flexible in creating apps i'm having huge trouble finding a reporting solution for my applicaiton. I have created an app to track and control time and expense which i want to generate timesheet, expense sheets, invoice etc from.
Having done some read i think XML is the best approach for me however i'm having huge troubles with my data model.
EXAMPLE:
I have 2 tables to start with, first table holds client information and the second table holds project information. One client can have many projects.
When i create the Data Model using SQL i get the obvious problem that when a client has more then one project my XML structure is incorrect.
SELECT gc.name AS CLIENT,
gp.name AS PROJECT
FROM gte_client gc,
gte_project gp
WHERE gc.client_id = gp.client_id(+)
The above SQL creates the following XML
- <ROWSET>
- <ROW>
<NAME>Symatrix Ltd</NAME>
<NAME>Symatrix Pre-Sales</NAME>
</ROW>
- <ROW>
<NAME>Aston Carter</NAME>
<NAME>MOD</NAME>
</ROW>
- <ROW>
<NAME>Symatrix Ltd</NAME>
<NAME>Fujitsu</NAME>
</ROW>
</ROWSET>
Obvious problem here is the fact that client Symatrix appears twice as there are 2 projects.
I have tried to write SQL/XML and i think i'm beginning to understand the structure of the XML functions however XMLPublisher doesn't appear to understand the syntax when creating a SQL Query for the data model.
I hope all this makes sense.
Kind Regards
GlenHi All,
Ok, so with a little searching through documents and articles on the web i found this information.
http://blogs.oracle.com/xmlpublisher/2006/05/05#a38
this details the exact thing i'm trying to achieve so anyone else who searches this forum with a similar problem check this out.
Regards
Glen -
How to tune the performance of Oracle SQL/XML query?
Hi all,
I am running Oracle 9i and like to run the following Oracle SQL/XML query. It takes about 3+ hour and still not finish. If I get rid all the XML stuffs it only take minutes to run. Does anybody know how to what's the reason of this slow and how to tune it?
SELECT XMLElement("CUSTOMER",
XMLForest(C_CUSTKEY "C_CUSTKEY", C_NAME "C_NAME", C_ADDRESS "C_ADDRESS", C_PHONE "C_PHONE", C_MKTSEGMENT "C_MKTSEGMENT", C_COMMENT "C_COMMENT"),
(SELECT XMLAgg(XMLElement("ORDERS",
XMLForest(O_ORDERKEY "O_ORDERKEY", O_CUSTKEY "O_CUSTKEY", O_ORDERSTATUS "O_ORDERSTATUS", O_ORDERPRIORITY "O_ORDERPRIORITY", O_CLERK "O_CLERK", O_COMMENT "O_COMMENT"),
(SELECT XMLAgg(XMLElement("LINEITEM",
XMLForest(L_ORDERKEY "L_ORDERKEY", L_RETURNFLAG "L_RETURNFLAG", L_LINESTATUS "L_LINESTATUS", L_SHIPINSTRUCT "L_SHIPINSTRUCT", L_SHIPMODE "L_SHIPMODE", L_COMMENT "L_COMMENT")
FROM LINEITEM
WHERE LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY)
FROM ORDERS
WHERE ORDERS.O_CUSTKEY = CUSTOMER.C_CUSTKEY)
FROM CUSTOMER ;
Thanks very much in advance for your time,
Jinghao Liuajallen wrote:
Why not something more like
SELECT *
FROM fact1 l,
FULL OUTER JOIN fact1 d
ON l.company = d.company
AND l.transactiontypeid = 1
AND d.transactiontypeid = 2;
Because this is not an equivalent of the original query.
drop table t1 cascade constraints purge;
drop table t2 cascade constraints purge;
create table t1 as select rownum t1_id from dual connect by level <= 5;
create table t2 as select rownum+2 t2_id from dual connect by level <= 5;
select * from (select * from t1 where t1_id > 2) t1 full outer join t2 on (t1_id = t2_id);
select * from t1 full outer join t2 on (t1_id = t2_id and t1_id > 2);
T1_ID T2_ID
3 3
4 4
5 5
6
7
T1_ID T2_ID
1
2
3 3
4 4
5 5
6
7 -
How to perf tune Oracle SQL/XML query?
Hi all,
I am using Oracle 9i and like to run the following Oracle SQL/XML query. It takes about 3+ hour and still not finish. If I get rid all the XML stuffs it only take minutes to run. Does anybody know how to what's the reason of this slow and how to tune it?
SELECT XMLElement("CUSTOMER",
XMLForest(C_CUSTKEY "C_CUSTKEY", C_NAME "C_NAME", C_ADDRESS "C_ADDRESS", C_PHONE "C_PHONE", C_MKTSEGMENT "C_MKTSEGMENT", C_COMMENT "C_COMMENT"),
(SELECT XMLAgg(XMLElement("ORDERS",
XMLForest(O_ORDERKEY "O_ORDERKEY", O_CUSTKEY "O_CUSTKEY", O_ORDERSTATUS "O_ORDERSTATUS", O_ORDERPRIORITY "O_ORDERPRIORITY", O_CLERK "O_CLERK", O_COMMENT "O_COMMENT"),
(SELECT XMLAgg(XMLElement("LINEITEM",
XMLForest(L_ORDERKEY "L_ORDERKEY", L_RETURNFLAG "L_RETURNFLAG", L_LINESTATUS "L_LINESTATUS", L_SHIPINSTRUCT "L_SHIPINSTRUCT", L_SHIPMODE "L_SHIPMODE", L_COMMENT "L_COMMENT")
FROM LINEITEM
WHERE LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY)
FROM ORDERS
WHERE ORDERS.O_CUSTKEY = CUSTOMER.C_CUSTKEY)
FROM CUSTOMER ;
Thanks very much in advance for your time,
Jinghao LiuPlease post this message at:
Forums Home » Oracle Technology Network (OTN) » Products » Database » XML DB -
Re-Write the Node-DOM code with SQL-XML funtions
Hi Friends,
Could you please help in re-writing the below code using SQl-XML functions
DECLARE
l_domdoc dbms_xmldom.DOMDocument;
l_xmltype XMLTYPE;
l_root_node dbms_xmldom.DOMNode;
l_departments_node dbms_xmldom.DOMNode;
l_dept_element dbms_xmldom.DOMElement;
l_dept_node dbms_xmldom.DOMNode;
l_name_node dbms_xmldom.DOMNode;
l_name_textnode dbms_xmldom.DOMNode;
l_location_node dbms_xmldom.DOMNode;
l_location_textnode dbms_xmldom.DOMNode;
l_employees_node dbms_xmldom.DOMNode;
l_emp_element dbms_xmldom.DOMElement;
l_emp_node dbms_xmldom.DOMNode;
l_emp_first_name_node dbms_xmldom.DOMNode;
l_emp_first_name_textnode dbms_xmldom.DOMNode;
l_emp_last_name_node dbms_xmldom.DOMNode;
l_emp_last_name_textnode dbms_xmldom.DOMNode;
BEGIN
-- Create an empty XML document
l_domdoc := dbms_xmldom.newDomDocument;
-- Create a root node
l_root_node := dbms_xmldom.makeNode(l_domdoc);
-- Create a new node Departments and add it to the root node
l_departments_node := dbms_xmldom.appendChild( l_root_node
, dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'Deptartments' ))
FOR r_dept IN (SELECT dept.department_id
, dept.department_name
, loc.city
FROM departments dept
JOIN locations loc
ON loc.location_id = dept.location_id
WHERE dept.department_id IN (10,20)
LOOP
-- For each record, create a new Dept element with the Department ID as attribute.
-- and add this new Dept element to the Departments node
l_dept_element := dbms_xmldom.createElement(l_domdoc, 'Dept' );
dbms_xmldom.setAttribute(l_dept_element, 'Deptno', r_dept.Department_Id );
l_dept_node := dbms_xmldom.appendChild( l_departments_node
, dbms_xmldom.makeNode(l_dept_element)
-- Each Dept node will get a Name node which contains the department name as text
l_name_node := dbms_xmldom.appendChild( l_dept_node
, dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'Name' ))
l_name_textnode := dbms_xmldom.appendChild( l_name_node
, dbms_xmldom.makeNode(dbms_xmldom.createTextNode(l_domdoc, r_dept.department_name ))
-- Each Dept node will aslo get a Location node which contains the location(city) as text
l_location_node := dbms_xmldom.appendChild( l_dept_node
, dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'Location' ))
l_location_textnode := dbms_xmldom.appendChild( l_location_node
, dbms_xmldom.makeNode(dbms_xmldom.createTextNode(l_domdoc, r_dept.city ))
-- For each department, add an Employees node
l_employees_node := dbms_xmldom.appendChild( l_dept_node
, dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'Employees' ))
FOR r_emp IN (SELECT employee_id
, first_name
, last_name
FROM employees
WHERE department_id = r_dept.department_id
LOOP
-- For each record, create a new Emp element with the Employee ID as attribute.
-- and add this new Emp element to the Employees node
l_emp_element := dbms_xmldom.createElement(l_domdoc, 'Emp' );
dbms_xmldom.setAttribute(l_emp_element, 'empid', r_emp.employee_id );
l_emp_node := dbms_xmldom.appendChild( l_employees_node
, dbms_xmldom.makeNode(l_emp_element)
-- Each emp node will get a First name and Last name node which contains the first name and last name as text
l_emp_first_name_node := dbms_xmldom.appendChild( l_emp_node
, dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'FirstName' ))
l_emp_first_name_textnode := dbms_xmldom.appendChild( l_emp_first_name_node
, dbms_xmldom.makeNode(dbms_xmldom.createTextNode(l_domdoc, r_emp.first_name ))
l_emp_last_name_node := dbms_xmldom.appendChild( l_emp_node
, dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'LastName' ))
l_emp_last_name_textnode := dbms_xmldom.appendChild( l_emp_last_name_node
, dbms_xmldom.makeNode(dbms_xmldom.createTextNode(l_domdoc, r_emp.last_name ))
END LOOP;
END LOOP;
l_xmltype := dbms_xmldom.getXmlType(l_domdoc);
dbms_xmldom.freeDocument(l_domdoc);
dbms_output.put_line(l_xmltype.getClobVal);
END;
thanks and regards,
Arun Thomas TIt's as easy as this :
SQL> select xmlserialize(document
2 xmlelement("Departments"
3 , xmlagg(
4 xmlelement("Dept"
5 , xmlattributes(d.department_id as "Deptno")
6 , xmlforest(
7 d.department_name as "Name"
8 , l.city as "Location"
9 )
10 , xmlelement("Employees"
11 , (
12 select xmlagg(
13 xmlelement("Emp"
14 , xmlattributes(e.employee_id as "empid")
15 , xmlforest(
16 e.first_name as "FirstName"
17 , e.last_name as "LastName"
18 )
19 )
20 )
21 from hr.employees e
22 where e.department_id = d.department_id
23 )
24 )
25 )
26 )
27 )
28 indent
29 )
30 from hr.departments d
31 join hr.locations l on l.location_id = d.location_id
32 where d.department_id in (10,20) ;
XMLSERIALIZE(DOCUMENTXMLELEMEN
<Departments>
<Dept Deptno="10">
<Name>Administration</Name>
<Location>Seattle</Location>
<Employees>
<Emp empid="200">
<FirstName>Jennifer</FirstName>
<LastName>Whalen</LastName>
</Emp>
</Employees>
</Dept>
<Dept Deptno="20">
<Name>Marketing</Name>
<Location>Toronto</Location>
<Employees>
<Emp empid="201">
<FirstName>Michael</FirstName>
<LastName>Hartstein</LastName>
</Emp>
<Emp empid="202">
<FirstName>Pat</FirstName>
<LastName>Fay</LastName>
</Emp>
</Employees>
</Dept>
</Departments> -
SQL server service accounts question
We created a test SQL environment using a Technet evaluation copy of Windows Server 2012 along with an evaluation copy of SQL2012. After testing, everything is working as planned so were going to enter the product keys for both Windows Server and SQL 2012.
My question is that once we have our Server licensed we’re going to start a new domain and recreate all the user accounts but I installed SQL using a local user account I created called ”sqladmin”. Once Server 2012 is the DC in the new domain will I need to
change all the service accounts for SQL in order for it to function or can I still use the local “sqladmin” user account? If I can re-use that local account are there any downside to that? What’s the best practice in this scenarioOnce Server 2012 is the DC in the new domain will I need to change all the service accounts for SQL in order for it to function or can I still use the local “sqladmin” user account? If I can re-use that local account are there any downside to that?
What’s the best practice in this scenario
Hi,
You can use your sqladmin account but that wont be a good security practice. You should always follow principal of least privilege and should run SQL server with domain account having least privilege.Below link will help you in this
Configure SQL server account and services
Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers
My TechNet Wiki Articles -
Can I use SQL/XML feature on EVERY Oracle DB?
I appreciate the SQL/XML as described here:
http://www.oracle.com/technology/oramag/oracle/03-may/o33xml.html
But I wonder if I can use these commands on EVERY Oracle DB.
Do I have to prepare/setup an existing DB in any way for receiving such SQL/XML commands ? Or do I have to enable this feature/install an Add-On?
Can I use this feature even with the Express Editions ?
PeterSQL/XML appears in 9.2.x and later. Not all of the operators in the current (11g) product are available in earlier releases. Please check the SQL reference guide for a particular version. However that article is quite old so it probably only refers to the ones in 9.2.x
-
Strange Behavior with SQL/XML
Our University have had for quite some time now a rather difficult situation with a very significant course handbook web site that creates HTML based on database XSL transformation of XML content generated with SQL/XML. The database is 10.2.0.2.0. The HTML is passed via a distributed database link to an Oracle Portal dynamic portlet for display. Some of the derived XML originates from XML Schema registered instance documents and some from relational storage.
Let me explain. Occasionally after a period of operating (could be one week, sometimes even less) we will experience a problem whereby our derived XML content (just prior to PL/SQL database XSL transformation) will develop a parsing problem. Once this happens to one XSL transform of a course then subsequently it happens for every course viewed/transformed there-after.
Recently I experienced the problem and then added the XMLNS argument to the extract function. That seemed to fix things and I thought I had it licked.
Today we started to get the same problem again. The error reported was:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00242: invalid use of ampersand ('&') character (use &)
Error at line 1
Now this might have been reasonable for one course. But every course reported the same problem there-after without fail. I managed to fix the issue but in a way that really doesn't seem to make sense. What I did was to alter the SQL/XML statement by adding in an extra XMLEMENT and then to recompile the function that returns an XMLTYPE based on the execution of the SQL statement. After compiling the function everything returned to normal.
This doesn't seem to make sense.
I am pretty desperate for help on this. I really don't know how to progress the solution. I don't get much joy from Oracle Support as our application covers too many high tech areas. This is really shaking confidence in our organization's use of Oracle technology.Hi Mark.
We've isolated the problem a bit more now and there is a support SR (6089662.994). At this stage we are unable to reproduce - I am testing out an export though. The problem only occurs when a certain condition has been reached. Once that happens then extraneous characters are produced in the XMLTYPE feed returned by a function. We are not at all sure about how to make this condition occur. This doesn't just happen with one SQL/XML cursor - I've seen it happen with 3 different cursors. All are located in the same function that returns an XMLTYPE.
We are convinced the problem lies with one or more SQL/XML cursors located in the same function. Once one of these cursors malfunctions it will produce XML that is not well formed OR on occasion has content omitted but is well formed (there often seem to be extraneous characters). When the XML content is not well formed then the parsing stage (dbms_xmlparser.parseclob(myparser, xml_clob)) of XSL transformation crashes. This error then propagates to the dynamic portlet in Oracle Portal thus removing the content on the page. This happens for every execution of the cursor while the condition manifests, the only difference between calls being bind variables.
The interesting thing is that the error if left to itself will eventually stop. The cursor seems to right itself eventually. On the last occurrence, the problem commenced at 4.30am and went for 3.5 hrs and then seemed to right itself. -
Sql/xml - powerful tool for complex reports
I just want to share euphoria...
HTMLDB itself provides powerful ways how to control the design of the page - various types of regions, page types, templates...
Nevertheless sometimes you need even more precise control over the content and format of the displayed page. The combination of SQL/XML and HTMLDB solves it in very elegant way.
- create page with common SQL report region.
- prepare the SELECT gathering the data to be displayed
- prepare another SELECT using SQL/XML functions adding HTML formating tags upon the first select.
Example:
select
XMLTYPE.getStringVal(
XMLElement("table",
XMLAttributes('5' as cellpadding),
XMLConcat(
XMLElement("tr",
XMLElement("td",
XMLAttributes('left' as align, 'top' as valign),
XMLElement("a",
XMLAttributes(provider_url as href),
XMLElement("img",XMLAttributes(provider_icon as src, provider_name as alt, provider_name as title))
XMLElement("td",
XMLAttributes('left' as align, 'top' as valign, '150' as width),
XMLElement("a",
XMLAttributes(event_url as href),
XMLElement("div",XMLAttributes('font-weight:bold; font-style:normal; font-size:10px; ' as style), event_name_part2)
XMLElement("div",XMLAttributes('font-weight:normal; font-style:normal; font-size:10px; ' as style), event_name_part1)
XMLElement("td",
XMLAttributes('right' as align, 'top' as valign),
XMLElement("div",
XMLElement("a",
XMLAttributes( edit_url as href),
XMLElement("img",
XMLAttributes( '#IMAGE_PREFIX#ed-item.gif' as src, '14' as width, '14' as height, 'Editovat článek/pořad' as alt, 'Editovat článek/pořad' as title)
XMLElement("div",
XMLElement("a",
XMLAttributes( delete_url as href),
XMLElement("img",
XMLAttributes( '#IMAGE_PREFIX#wastebasket.gif' as src, '16' as width, '16' as height, 'Smazat článek/pořad' as alt, 'Smazat článek/pořad' as title)
) as event_description
from (select
case
when EVENT_PROVIDER_TYPE='Magazine' then set_1 || ' ' || set_2 || ' ' || set_3 || ' ' || set_4
when EVENT_PROVIDER_TYPE='Radio' then set_1 || ' ' || set_2 || ' ' || set_3 || ' ' || set_4
when EVENT_PROVIDER_TYPE='Author' then set_2
end as event_name_part1,
case
when EVENT_PROVIDER_TYPE='Magazine' then set_5 || ' ' || set_6
when EVENT_PROVIDER_TYPE='Radio' then set_5 || ' ' || set_6
when EVENT_PROVIDER_TYPE='Author' then set_1
end as event_name_part2,
events.url as event_url,
my_events.issue_date,
providers.icon_path as provider_icon,
providers.provider_name,
case
when substr(upper(providers.www_address),1,7)<>'HTTP://'
then 'http://' || providers.www_address
else providers.www_address
end as provider_url,
'f?p=' || v('APP_ID') || ':2:' || v('SESSION') || '::NO:16:P2_EVENT_ID,P2_EVENT_NAME:' || events.event_id || ',' || events.event_name as delete_url,
'f?p=' || v('APP_ID') || ':35:' || v('SESSION') || '::NO:35:P35_SELECTED_EVENT_ID,P35_SELECTED_EVENT_NAME:' || events.event_id || ',' || events.event_name as edit_url
from my_events
join events on my_events.event_id=events.event_id
join providers on EVENTS.PROVIDER_ID= PROVIDERS.PROVIDER_ID
where my_events.user_id=:IAL_USER_ID
order by my_events.issue_date desc)
P.S. It's cool to use XMLAGG function in combination with GROUP BY clause - it enables you to easily display list of strings as a single filed on the formular....You will be able to use our XSL Processor to format into HTML or
CSV once it is released next month. Adobe is sponsoring a
context for a PDF engine for XML.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
Karl Reitschuster (guest) wrote:
: We are developing an IntranetApplication with Oracle Webserver
: and Oracle DB.
: Reports should be generated in HTML or PDF or CSV.
: IS there any tool which can generate these formats on XML-Base.
: How do you generate your documentation which is both in PDF
and
: HTML?
: For any Tips : thank you
null -
Creating optional elements using SQL / XML functions
Hi,
I am struggling with some SQL / XML functionality in order to create some optional elements in a XMLType.
I have one table with data to be generated into an XML document. The table looks like this (only the attributes related to the problem are shown):
msg_id (pk)
geslacht_hoofdverzekerde
geboortedatum_hoofdverzekerde
geslacht_medeverzekerde
geboortedatum_medeverzekerde
I have to create an XML document that looks like this:
<ber:rekenparameters>
<ber:verzekerde>
<ber:codeRelatierol>HVZ</ber:codeRelatierol>
<ber:geslacht>M</ber:geslacht>
<ber:datumGeboorte>01-01-1960</ber:datumGeboorte>
</ber:verzekerde>
<ber:verzekerde>
<ber:codeRelatierol>MVZ</ber:codeRelatierol>
<ber:geslacht>V</ber:geslacht>
<ber:datumGeboorte>01-01-1961</ber:datumGeboorte>
</ber:verzekerde>
</ber:rekenparameters>
Where <ber:codeRelatierol> is hard coded: i.c. of hoofverzekerde 'HVZ' in case of medeverzekerde 'MVZ'.
Geslacht en datumGeboorte are taken form the table.
The element <ber:verzekerde> is obligatiry for hoofdverzekerde but optional for medeverzekerde: only in case geslacht_medeverzekerde and geboortedatum_medeverzekerde are not null this 2nd <ber:verzekerde> element has to be added.
I created the next SQL (I skipped some stuff in order to focus on the problem):
CREATE OR REPLACE
VIEW dps_v_berekening_berichten
AS
SELECT msg_id as msg_id
, XMLElement( "ber:berekening"
, XMLAttributes( 'http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi"
, 'http://www.mycompany.nl/berekenen' AS "xmlns:ber"
, 'http://www.mycompany.nl/berekenen http://www.mycompany.nl/berekenen/berekening.xsd' AS "xsi:schemaLocation"
, XMLElement( "ber:nummerRekenRegel"
, XMLAttributes( 'http://www.mycompany.nl/berekenen' AS "xmlns:ber" )
, 1
, XMLElement( "ber:rekenparameters"
, XMLAttributes( 'http://www.mycompany.nl/berekenen' AS "xmlns:ber" )
, XMLElement( "ber:codeEvolutie" ) -- Empty
, XMLElement( "ber:verzekerde"
, XMLForest ( 'HVZ' AS "ber:codeRelatierol"
, xoa.geslacht_hoofdverzekerde AS "ber:geslacht"
, xoa.geboortedatum_hoofdverzekerde AS "ber:datumGeboorte"
, XMLElement( "ber:verzekerde"
, XMLForest ( 'MVZ' AS "ber:codeRelatierol"
, xoa.geslacht_medeverzekerde AS "ber:geslacht"
, xoa.geboortedatum_medeverzekerde AS "ber:datumGeboorte"
-- Some more elements.
) AS bericht
FROM DST_UP1_XML_OUTDATA xoa
The problem is that the XMLForest always creates an <ber:verzekerde> element for medeverzekerde. I tried to create an inline view with just the "vezekerde"attributes and conditionally joining this inline view with the dst_up1_xml_outdata table. That didn't solve my problem. Because in case of a medeverzekerde available it returned two XML documenst: one that included the hoofdverzekerde and one that included the medeverzekerde. And obviously that's not what I want.
I imagine I have to juggle with some of these SQL / XML functions although I cannot put the finger on the exact differences between some of these (XMLElement, XMLForest, XMLAgg, XMLSequence). The examples shown in de XML DB Developer's Guide don't seem to adress my problem.
Help !Hi, are you talking about this part that you don't want to be there? I am not so clear about your requirements.
XMLElement( "ber:verzekerde"
, XMLForest ( 'MVZ' AS "ber:codeRelatierol"
, xoa.geslacht_medeverzekerde AS "ber:geslacht"
, xoa.geboortedatum_medeverzekerde AS "ber:datumGeboorte"
If you want to control certain subelements so they don't appear, do not use xmlforest. Use xmlelement instead so it is easier to control it using case when. Mark (of Oracle, he should be here soon since OOW is over) showed me this technique and it helps tremendously, because oftentimes XDB will return an empty tag even though your consumers don't like it!
try something like this,
(case when xoa.geboortedatum_medeverzekerde = 'MVZ' then
xmlelement("ber:verzekerde",
xmlelement("What you want", colname),
xmlelement("ber:codeRelatierol", 'MVZ'),
(case when colname is not null or = some other value then
xmlelement("Rest", colname))
end)
end),
You may have to twig some details there. But the key is to use the case when construct to get rid of unwanted elements or empty elements. So you should only have the elements if you have a value of 'MVZ'. Hope this helps.
Ben
Maybe you are looking for
-
Not able to open web analysis reports after upgradation
we have upgraded Hyperion 11.1.1.3 to 11.1.2.2 version, after this process we are not able to open web analysis reports These reports are still pointing to old servers so, how to edit this database connection details in the new version?? Edited by: 1
-
I can't search for book or authors in ibooks. When I search an author or book and click on it a message that says not results found comes up. Even if I try to look up something popular like Dracula or Twilight. Is there some setting I should have
-
RE: Cannot use my skype online number have pay for...
You should be able to start using your purchase immediately. However, in some cases, you may have to wait up to an hour for it to be activated. If you're still having problems, visit our help section. Have try to use my online number is not working h
-
[TV@Plus] record sound garbeled after recording
Just installed for first time Recording seems to be ok, after play back of the mp3 file in windows, the sound is badly garbled TV @nywhere plus driver 2.4.0.4
-
Sourcing 7.0 Workflow Error
Hi , We are working on Sourcing 7.0 Workflow process for Contract Document.We have associated some of the contract Phase Configuration with workflow Definitions so that when there is a phase change, the respective workflow defined will get executed.C