Parse OraclePreparedStatement
I'm using Oracle 8.1.6 and Java
Code snip:
PreparedStatement ps =
conn.prepareStatement ("insert into dept (deptno) values (?)");
for (i = 1; i < 4; i++) {
for (k = 1; k < 5; k++) {
ps.setInt (1, k+i*10);
ps.executeUpdate ();
((OraclePreparedStatement)ps).sendBatch ();
With TKPROF we have following trace
insert into dept (deptno)
values (:1)
call count cpu
Parse 3 0.04
Execute 3 0.00
Fetch 0 0.00
total 6 0.04
I estimate (and hope) only one Parse of the OraclePreparedStatement ...
Could someone please help me with this?
Thank you in advance.
Horst Zein
teklife wrote:
i uploaded my iweb created site, via ftp, to web hosting site.
ssameer ~ It may be useful to indicate whether you used iWeb's built-in FTP app or another one. If you're using another one, indicate the name of the FTP app and confirm that you correctly uploaded both the Index folder and the folder(s) named as your site.
Also, you can see the source of the page Safari is trying to load by clicking on the View menu in Safari and choosing +View Source+.
Similar Messages
-
How do I get an OraclePreparedStatement from a DataSource?
I'm trying to parse XML data types from an Oracle 10g database. The Oracle recommended way of doing this is as follows:
Connection conn = ....
OraclePreparedStatement stmt = (OraclePreparedStatement)conn.prepareStatement( "..." );
OracleResultSet rs = (OracleResultSet)stmt.execute();
while( rs.next() ) {
OPAQUE opaque = rs.getOPAQUE(1);
XMLType xml = opaque.createXML( opaque );
and then you go from there. This all works great when I manually create the connection using the non-j2ee method of directly connecting to the database using the jdbc:oracle:thin driver. However, when I try to allocate a connection using the J2EE defined data source, I can't do the above since the classes returned to me are SAP types, and don't take kindly to being cast to Oracle types.
Is there a way to do this? I've done some digging, but I haven't found the end of the tunnel yet I can always connect directly to the database, but I would rather use the data source management service of the J2EE engine.
Thanks!I did try it, and I got a cast exception....read on:
I've added the SAP-J2E/dbpool DC to my project, and tried the following code:
import oracle.jdbc.OracleResultSet;
import oracle.jdbc.driver.OraclePreparedStatement;
import com.sap.engine.services.dbpool.cci.ConnectionHandle;
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/XILOG");
System.err.println("Datasource is " + ds);
ConnectionHandle handle = (ConnectionHandle)ds.getConnection();
System.err.println("Connection Handle is " + handle);
Connection conn = handle.getPhysicalConnection();
if (Class.forName("oracle.jdbc.driver.OracleConnection").isInstance(conn)) {
System.err.println("INSTANCE OF ORACLE DERIVER");
System.err.println("Connection is " + conn);
PreparedStatement stmt = conn.prepareStatement("select 1 from dual");
System.err.println("Prepared Statement is " + stmt);
// !!! causes exception below !!!
OraclePreparedStatement ostmt = (OraclePreparedStatement)stmt;
System.err.println("Oracle Prepared Statement is " + ostmt);
I get this exception, and the messages displayed afterward:
Date , Time , Message , Severity , Category , Location , Application , User
01/30/2006 , 8:56:58:967 ,
[EXCEPTION]
com.sap.engine.services.ejb.exceptions.BaseEJBException: Exception in method sendKey.
at ca.example.dxi.ejb.TestServiceEJBLocalLocalObjectImpl0.sendKey(TestServiceEJBLocalLocalObjectImpl0.java:119)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:126)
at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:157)
at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:79)
at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)
at SoapServlet.doPost(SoapServlet.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
Caused by: java.lang.ClassCastException
at ca.example.dxi.ejb.TestServiceEJBBean.sendKey(TestServiceEJBBean.java:68)
at ca.example.dxi.ejb.TestServiceEJBLocalLocalObjectImpl0.sendKey(TestServiceEJBLocalLocalObjectImpl0.java:103)
... 25 more
++++++++++++++++++++++++++++++++++++++++
java.lang.ClassCastException
+++++++++++++++++++++++++++++++++++++++++
at ca.example.dxi.ejb.TestServiceEJBBean.sendKey(TestServiceEJBBean.java:68)
at ca.example.dxi.ejb.TestServiceEJBLocalLocalObjectImpl0.sendKey(TestServiceEJBLocalLocalObjectImpl0.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:126)
at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:157)
at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:79)
at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)
at SoapServlet.doPost(SoapServlet.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
, Error , , com.sap.engine.services.ejb , example.ca/dxi~ear~testsvc , Guest
01/30/2006 , 8:56:58:951 , Prepared Statement is oracle.jdbc.driver.OraclePreparedStatement@cff2b9 , Error , , System.err , example.ca/dxi~ear~testsvc , Guest
01/30/2006 , 8:56:58:951 , Connection is oracle.jdbc.driver.OracleConnection@58d06b , Error , , System.err , example.ca/dxi~ear~testsvc , Guest
01/30/2006 , 8:56:58:951 , Connection Handle is com.sap.engine.services.dbpool.cci.ConnectionHandle@8f198d , Error , , System.err , example.ca/dxi~ear~testsvc , Guest
01/30/2006 , 8:56:58:951 , Datasource is com.sap.engine.services.dbpool.cci.ConnectionFactoryImpl@761e7d , Error , , System.err , example.ca/dxi~ear~testsvc , Guest
I'm not sure what's going on, since the returned type is an OraclePreparedStatement. Also, you'll notice that the 'instanceof' check fails. I'm wondering if I'm not having a class loader issue, where the classes used by the datasource application (which come from classes12.zip which I uploaded) are clashing with the classes pointed to via a hard runtime reference to a j2ee library project that also contains classes12.zip and two other oracle-specific jar files used for dealing with xml and the XMLTYPE column type.
I've tried a few variations, but every time I try to cast the returned object to the corresponding Oracle type, I get a casting exception.
Suggestions? -
Is there a SAX parser with PL/SQL??
Hi All,
I am a Oracle developer and generally want to do everything from PL/SQL.
So, from a PL/SQL procedure I would like to parse a XML document. I have tried hard to find a PL/SQL package which can give me a PL/SQL SAX parser, but could not find one.
All packages are based on DOM tree.
Please convey if I am wrong and is there a SAX parser?
I know that there is only one package DBMS_XMLSTORE which is C based and uses SAX parser, but it does not have procedures/functions like ".parse()".
Thanks and regardsHere's an example
SQL> --
SQL> define MODULE=SaxProcessor
SQL> define CLASS=com/oracle/st/xmldb/pm/examples/SaxProcessor
SQL> --
SQL> set define off
SQL> --
SQL> var sourceFileName varchar2(32)
SQL> var targetPath varchar2(1024)
SQL> --
SQL> begin
2 :sourceFileName := 'JavaSource';
3 :targetPath := '/public/' || :sourceFileName || '.java';
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> declare
2 res boolean;
3 javaSource clob :=
4 'package com.oracle.st.xmldb.pm.examples;
5
6
7 import java.io.IOException;
8 import java.io.StringWriter;
9
10 import java.io.Writer;
11
12 import java.sql.DriverManager;
13 import java.sql.SQLException;
14
15 import java.util.Enumeration;
16 import java.util.Hashtable;
17
18 import oracle.jdbc.OracleConnection;
19 import oracle.jdbc.OracleDriver;
20
21 import oracle.jdbc.OraclePreparedStatement;
22
23 import oracle.sql.BFILE;
24
25 import oracle.sql.CLOB;
26
27 import oracle.xml.parser.v2.SAXParser;
28 import oracle.xml.parser.v2.XMLDocument;
29 import oracle.xml.parser.v2.XMLElement;
30
31
32 import org.w3c.dom.Attr;
33 import org.w3c.dom.Element;
34 import org.w3c.dom.Node;
35
36 import org.xml.sax.Attributes;
37 import org.xml.sax.ContentHandler;
38 import org.xml.sax.Locator;
39 import org.xml.sax.SAXException;
40
41 public class SaxProcessor implements ContentHandler {
42
43 public static final boolean DEBUG = true;
44
45 private OracleConnection dbConnection;
46
47 private OraclePreparedStatement insertStatement;
48 private OraclePreparedStatement errorStatement;
49 private CLOB clob;
50
51 private Hashtable namespaceToPrefix = null;
52 private Hashtable prefixToNamespace = null;
53 private String targetElementName = null;
54
55 private XMLDocument currentDocument;
56 private Node currentNode;
57
58 private int documentCount = 0;
59
60 public SaxProcessor() {
61 this.namespaceToPrefix = new Hashtable();
62 this.prefixToNamespace = new Hashtable();
63 }
64
65 private boolean isTargetElement(String elementName) {
66 return ((this.currentDocument == null) &&
67 (elementName.equals(this.targetElementName)));
68 }
69
70 public void startDocument() throws SAXException {
71 }
72
73 public void endDocument() throws SAXException {
74 }
75
76 public void startElement(String namespaceURI, String localName, String elementName, Attributes attrs)
77 throws SAXException
78 {
79 if (DEBUG) {
80 System.out.println("startElement() : URI = " + namespaceURI + ", localName = " + localName + ", elementName = " + elementNa
me);
81 }
82 if (this.currentDocument == null)
83 {
84 if (DEBUG) {
85 System.out.println("startElement() : Checking for start of Fragment.");
86 }
87 if (isTargetElement(localName))
88 {
89 if (DEBUG) {
90 System.out.println("startElement() : Starting New Document");
91 }
92 this.currentDocument = new XMLDocument();
93 this.currentNode = this.currentDocument;
94 XMLElement rootElement = createNewElement(namespaceURI, localName, elementName, attrs);
95 this.currentDocument.appendChild(rootElement);
96 this.currentNode = rootElement;
97 }
98 }
99 else
100 {
101 XMLElement nextElement = createNewElement(namespaceURI, localName, elementName, attrs);
102 this.currentNode.appendChild(nextElement);
103 this.currentNode = nextElement;
104 }
105 }
106
107 public void endElement(String namespaceURI, String localName, String qName)
108 throws SAXException
109 {
110 if (this.currentDocument != null)
111 {
112 if (this.currentNode.equals(this.currentDocument.getDocumentElement()))
113 {
114 try
115 {
116 insertDocument();
117 this.currentDocument = null;
118 }
119 catch (SQLException sqlE)
120 {
121 throw new SAXException(sqlE);
122 }
123 catch (IOException ioe)
124 {
125 throw new SAXException(ioe);
126 }
127 }
128 else
129 {
130 this.currentNode = this.currentNode.getParentNode();
131 }
132 }
133 }
134
135 private XMLElement createNewElement(String namespaceURI, String localName,
136 String elementName, Attributes attrs) {
137 XMLElement newElement = null;
138 if (namespaceURI != null) {
139 if (this.namespaceToPrefix.containsKey(namespaceURI)) {
140 /* Namespace in already in Scope - create Element from Qualified Name */
141 newElement =
142 (XMLElement)this.currentDocument.createElement(elementName);
143 } else {
144 /* Namespace is not already in Scope - create Element with namespace */
145 newElement =
146 (XMLElement) this.currentDocument.createElementNS(namespaceURI,
147 elementName);
148 newElement.setPrefix((String)this.namespaceToPrefix.get(namespaceURI));
149 }
150 } else {
151 newElement =
152 (XMLElement)this.currentDocument.createElement(localName);
153 }
154 addAttributes(newElement, attrs);
155 if (this.currentNode.equals(this.currentDocument)) {
156 addNamespaceDeclarations(newElement);
157 }
158 return newElement;
159 }
160
161 private void addAttributes(Element element, Attributes attrs) {
162 for (int i = 0; i < attrs.getLength(); i++) {
163 if (attrs.getURI(i).equals("http://www.w3.org/2000/xmlns/")) {
164 } else {
165 element.setAttribute(attrs.getQName(i), attrs.getValue(i));
166 }
167 }
168 }
169
170 private void addNamespaceDeclarations(Element element) {
171 Enumeration keys = this.namespaceToPrefix.keys();
172 while (keys.hasMoreElements()) {
173 String namespace = (String)keys.nextElement();
174 String prefix = (String)namespaceToPrefix.get(namespace);
175 Attr attr = null;
176 if (prefix.equals("")) {
177 attr = this.currentDocument.createAttribute("xmlns");
178 attr.setValue(namespace);
179 element.setAttributeNode(attr);
180 } else {
181 if (!prefix.equals(element.getPrefix())) {
182 attr =
183 this.currentDocument.createAttribute("xmlns:" + prefix);
184 attr.setValue(namespace);
185 element.setAttributeNode(attr);
186 }
187 }
188 }
189 }
190
191 public void characters(char[] p0, int p1, int p2) throws SAXException {
192 if (this.currentDocument != null) {
193 StringWriter sw = new StringWriter();
194 sw.write(p0, p1, p2);
195 String value = sw.toString();
196 Node textNode = this.currentDocument.createTextNode(value);
197 this.currentNode.appendChild(textNode);
198 }
199 }
200
201 public void startPrefixMapping(String prefix,
202 String uri) throws SAXException {
203 this.namespaceToPrefix.put(uri, prefix);
204 this.prefixToNamespace.put(prefix, uri);
205 }
206
207 public void endPrefixMapping(String prefix) throws SAXException {
208 Enumeration e = prefixToNamespace.keys();
209 while (e.hasMoreElements()) {
210 String thisPrefix = (String)e.nextElement();
211 if (thisPrefix.equals(prefix)) {
212 String namespace =
213 (String)prefixToNamespace.remove(thisPrefix);
214 namespaceToPrefix.remove(namespace);
215 }
216 }
217 }
218
219 public void ignorableWhitespace(char[] p0, int p1,
220 int p2) throws SAXException {
221 // throw new SAXException ("Un-Implemented Method: ingnoreableWhitespace");
222 }
223
224 public void processingInstruction(String p0,
225 String p1) throws SAXException {
226 throw new SAXException("Un-Implemented Method: processingInstruction");
227 }
228
229 public void setDocumentLocator(Locator p0) {
230 // throw new SAXException ("Un-Implemented Method: setDocumentLocator");
231 }
232
233 public void skippedEntity(String p0) throws SAXException {
234 throw new SAXException("Un-Implemented Method: skippedEntity");
235 }
236
237 public void doParse(BFILE bfile, String targetElement,
238 String targetTable, String errorTable) throws Exception {
239 this.targetElementName = targetElement;
240 String insertStatementText =
241 "insert into " + targetTable + " values (xmlParse(DOCUMENT ? WELLFORMED))";
242 String errorStatementText =
243 "insert into " + errorTable + " values (xmlParse(DOCUMENT ? WELLFORMED))";
244
245 DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
246 OracleDriver ora = new OracleDriver();
247 this.dbConnection = (OracleConnection)ora.defaultConnection();
248
249 this.insertStatement =
250 (OraclePreparedStatement)this.dbConnection.prepareStatement(insertStatementText);
251 this.errorStatement =
252 (OraclePreparedStatement)this.dbConnection.prepareStatement(errorStatementText);
253
254 this.clob =
255 CLOB.createTemporary(this.dbConnection, true, CLOB.DURATION_SESSION);
256
257 SAXParser parser = new SAXParser();
258 parser.setAttribute(SAXParser.STANDALONE, Boolean.valueOf(true));
259 parser.setValidationMode(SAXParser.NONVALIDATING);
260 parser.setContentHandler(this);
261 bfile.openFile();
262 parser.parse(bfile.getBinaryStream());
263 bfile.closeFile();
264 this.insertStatement.close();
265 this.errorStatement.close();
266 }
267
268 private void insertDocument() throws SQLException, IOException {
269 this.clob.truncate(0);
270 Writer out = clob.setCharacterStream(0);
271 this.currentDocument.print(out);
272 out.close();
273
274 this.insertStatement.setClob(1, clob);
275 this.insertStatement.execute();
276
277 this.documentCount++;
278
279 if (DEBUG) {
280 System.out.println("insertDocument() : Document Inserted");
281 }
282 }
283
284 public static int parseBFile(BFILE bfile, String targetElement,
285 String targetTable, String errorTable) throws Exception {
286 try {
287 SaxProcessor processor = new SaxProcessor();
288 processor.doParse(bfile,targetElement,targetTable,errorTable);
289 return processor.documentCount;
290 }
291 catch (Exception e) {
292 e.printStackTrace(System.out);
293 throw e;
294 }
295
296 }
297 }
298 ';
299 begin
300 if dbms_xdb.existsResource(:targetPath) then
301 dbms_xdb.deleteResource(:targetPath);
302 end if;
303 res := dbms_xdb.createResource(:targetPath,javaSource);
304 end;
305 /
Queuing DELETE Event
PL/SQL procedure successfully completed.
SQL> --
SQL> set define on
SQL> --
SQL> create or replace and resolve java source
2 named "&MODULE"
3 using blob
4 (
5 select xdburiType('/public/JavaSource.java').getBlob(nls_charset_id('WE8ISO8859P1'))
6 from dual
7 )
8 /
old 2: named "&MODULE"
new 2: named "SaxProcessor"
Java created.
SQL> show errors
No errors.
SQL> --
SQL> declare
2 shortname varchar2(128);
3 begin
4 shortname := dbms_java.shortname('&CLASS');
5 execute immediate 'grant execute on "' || shortname || '" to public';
6 end;
7 /
old 4: shortname := dbms_java.shortname('&CLASS');
new 4: shortname := dbms_java.shortname('com/oracle/st/xmldb/pm/examples/SaxProcessor');
PL/SQL procedure successfully completed.
SQL> create or replace package SAX_PROCESSOR
2 as
3 procedure PARSE_BFILE(file BFILE, targetElement varchar2, targetTable varchar2, errorTable varchar2);
4 end;
5 /
Package created.
SQL> show errors
No errors.
SQL> --
SQL> create or replace package body SAX_PROCESSOR
2 as
3 --
4 procedure PARSE_BFILE(file BFILE, targetElement varchar2, targetTable varchar2, errorTable varchar2)
5 AS LANGUAGE JAVA
6 NAME 'com.oracle.st.xmldb.pm.examples.SaxProcessor.parseBFile( oracle.sql.BFILE, java.lang.String, java.lang.String, java.lang.Strin
g)';
7 end;
8 /
Package body created.
SQL> show errors
No errors.
SQL> --
SQL> drop table PO_TEST
2 /
Table dropped.
SQL> create table PO_TEST of XMLTYPE
2 /
Table created.
SQL> drop table PO_ERROR
2 /
Table dropped.
SQL> create table PO_ERROR of XMLTYPE
2 /
Table created.
SQL> create or replace directory xmldir as 'c:\temp'
2 /
Directory created.
SQL> set serveroutput on
SQL> --
SQL> call SAX_PROCESSOR.PARSE_BFILE(bfilename('XMLDIR','testcase.xml'),'PurchaseOrder','PO_TEST','PO_ERROR')
2 /
call SAX_PROCESSOR.PARSE_BFILE(bfilename('XMLDIR','testcase.xml'),'PurchaseOrder','PO_TEST','PO_ERROR')
ERROR at line 1:
ORA-29549: class XFILES.com/oracle/st/xmldb/pm/examples/SaxProcessor has
changed, Java session state cleared
SQL> call SAX_PROCESSOR.PARSE_BFILE(bfilename('XMLDIR','testcase.xml'),'PurchaseOrder','PO_TEST','PO_ERROR')
2 /
Call completed.
SQL> select count(*) from PO_TEST
2 /
3
SQL> select * from PO_TEST
2 /
<PurchaseOrder xsi:noNamespaceSchemaLocation="http://xfiles:8080/home/SCOTT/poSo
urce/xsd/purchaseOrder.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
">
<Reference>AMCEWEN-20030409123336271PDT</Reference>
<Actions>
<Action>
<User>KPARTNER</User>
</Action>
</Actions>
<Reject/>
<Requestor>Allan D. McEwen</Requestor>
<User>AMCEWEN</User>
<PurchaseOrder xsi:noNamespaceSchemaLocation="http://xfiles:8080/home/SCOTT/poSo
urce/xsd/purchaseOrder.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
">
<Reference>SKING-20030409123336321PDT</Reference>
<Actions>
<Action>
<User>SKING</User>
</Action>
</Actions>
<Reject/>
<Requestor>Steven A. King</Requestor>
<User>SKING</User>
<PurchaseOrder xsi:noNamespaceSchemaLocation="http://xfiles:8080/home/SCOTT/poSo
urce/xsd/purchaseOrder.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
">
<Reference>SMCCAIN-20030409120030451PDT</Reference>
<Actions>
<Action>
<User>SVOLLMAN</User>
</Action>
</Actions>
<Reject/>
<Requestor>Samuel B. McCain</Requestor>
<User>SMCCAIN</User>
SQL> -
How can I use a 3rd party XML parser such as xerces with OC4J ?
Hi all tech experts,
I am using Oracle Application Server 10g Release 2 (10.1.2) and i have
installed Portal and Wireless and OracleAS Infrastructure on the same
computer.
i tried all the solutions on this thread
Use of Xerces Parser in out application with Oracle App Server 9.0.4
but still fighting.
I have also posted this query on OTN on following thread
How can I use a 3rd party XML parser such as xerces with OC4J?
but no reply....
Please help me on this issue.
Since OC4J is preconfigured to use the Oracle XML parser which is xmlparserv2.jar.
i have read the following article which states that
OC4J is preconfigured to use the Oracle XML parser. The Oracle XML parser is fully JAXP 1.1 compatible and will serve the needs of applications which require JAXP functionality. This approach does not require the download, installation, and configuration of additional XML parsers.
The Oracle XML parser (xmlparserv2.jar) is configured to load as a system level library of OC4J through it's inclusion as an entry in the Class-Path entry of the oc4j.jar Manifest.mf file. This results in the Oracle XML parser being used for all common deployment and packaging situations. You are not permitted to modify the Manifest.mf file of oc4j.jar.
It must be noted that configuring OC4J to run with any additional XML parser or JDBC library is not a supported configuration. We do know customers who have managed to successfully replace the system level XML parser and the Oracle JDBC drivers that ship with the product, but we do not support this type of configuration due to the possibility of unexpected system behavior and system errors that might occur from replacing the tested and certified libraries.
If you absolutely must use an additional XML parser such as xerces, then you have to start OC4J such that the xerces.jar file is loaded at a level above the OC4J system classpath. This can be accomplished using the -Xbootclasspath flag of the JRE.
i have also run the following command
java -Xbootclasspath/a:d:\xerces\xerces.jar -jar oc4j.jar
but no success.
How could i utilize my jar's like xerces.jar and xalan.jar for parsing instead of OC4J in-built parser ?
All reply will be highly appreciated.
Thnx in advance to all.
Neeraj Sidhaye
try_catch_finally @ Y !Hi Neeraj Sidhaye,
I am trying to deploy a sample xform application to the Oracle Application Server (10.1.3). However, I encountered the class loader issue that is similar to your stuation. I tried all the three solutions but the application is still use the Oracle xml paser class. I am wondering if you have any insight about this?
Thanks for your help.
Xingsheng Qian
iPass Inc.
Here is the error message I got.
Message:
java.lang.ClassCastException: oracle.xml.parser.v2.XMLElement
Stack Trace:
org.chiba.xml.xforms.exception.XFormsException: java.lang.ClassCastException: oracle.xml.parser.v2.XMLElement
at org.chiba.xml.xforms.Container.dispatch(Unknown Source)
at org.chiba.xml.xforms.Container.dispatch(Unknown Source)
at org.chiba.xml.xforms.Container.initModels(Unknown Source)
at org.chiba.xml.xforms.Container.init(Unknown Source)
at org.chiba.xml.xforms.ChibaBean.init(Unknown Source)
at org.chiba.adapter.servlet.ServletAdapter.init(ServletAdapter.java:153)
at org.chiba.adapter.servlet.ChibaServlet.doGet(ChibaServlet.java:303)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:719)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:299)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:187)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassCastException: oracle.xml.parser.v2.XMLElement
at org.chiba.xml.xforms.Instance.iterateModelItems(Unknown Source)
at org.chiba.xml.xforms.Bind.initializeModelItems(Unknown Source)
at org.chiba.xml.xforms.Bind.init(Unknown Source)
at org.chiba.xml.xforms.Initializer.initializeBindElements(Unknown Source)
at org.chiba.xml.xforms.Model.modelConstruct(Unknown Source)
at org.chiba.xml.xforms.Model.performDefault(Unknown Source)
at org.chiba.xml.xforms.XFormsDocument.performDefault(Unknown Source)
at org.chiba.xml.xforms.XFormsDocument.dispatchEvent(Unknown Source)
at org.apache.xerces.dom.NodeImpl.dispatchEvent(Unknown Source)
... 18 more -
Xml parsing error in JSP 1.2
Hi, everyone.
I'm getting an error trying precompile JSP code using a variable tag in my tag library to define a new scripting variable : Element "tag" does not allow "variable" here.
I also get the same error after deployng the JSP code on Sun One Application server 7.
Any idea?
Thanks a lot for any help.Here is the tag lib file that can't be parsed.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_2.dtd">
<!-- a tag library descriptor -->
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>er</short-name>
<uri></uri>
<description>
A tab library for iteration tag used in Event Reminder application
</description>
<tag>
<name>loopEvent</name>
<tag-class>com.abnamro.na.net.reminder.servlet.IterateTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>collection</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<variable>
<name-given>mmdd</name-given>
<variable-class>String</variable-class>
<declare>true</declare>
<scope>NESTED</scope>
<description>month and day of event</description>
</variable>
<variable>
<name-given>type</name-given>
<variable-class>String</variable-class>
<declare>true</declare>
<scope>NESTED</scope>
<description>This variable contains type of event</description>
</variable>
<variable>
<name-given>name</name-given>
<variable-class>String</variable-class>
<declare>true</declare>
<scope>NESTED</scope>
<description>This variable contains name of event</description>
</variable>
<variable>
<name-given>period</name-given>
<variable-class>String</variable-class>
<declare>true</declare>
<scope>NESTED</scope>
<description>period over which a user get a email for</description>
</variable>
<variable>
<name-given>descr</name-given>
<variable-class>String</variable-class>
<declare>true</declare>
<scope>NESTED</scope>
<description>description</description>
</variable>
<variable>
<name-given>numyears</name-given>
<variable-class>String</variable-class>
<declare>true</declare>
<scope>NESTED</scope>
<description>number of years for particular event</description>
</variable>
<variable>
<name-given>address</name-given>
<variable-class>String</variable-class>
<declare>true</declare>
<scope>NESTED</scope>
<description>address of event</description>
</variable>
<variable>
<name-given>phone</name-given>
<variable-class>String</variable-class>
<declare>true</declare>
<scope>NESTED</scope>
<description>phone of event</description>
</variable>
</tag>
</taglib>
Thank you. -
Issue in parsing the response of a WebService in Service Link
I am getting issues in connecting an external (non cisco) application via WebService. Appreciate if anyone can help in fixing the issue. I am using 9.3.2 Patch 6.
Connectivity to an external system (a 3rd party application in my firm) was achieved via WebService using the ServiceLink module.
Used the Outbound HTTP/WS Adapter where I am sending request and receiving response (bi-direction).
Successfully constructed and passed the XML request to the WebService.
Received response from the WebService as an XML / Soap Message which is then wrapped with the <Message> tag with the channel-id attribute successfully.
Designed a XSL Transformation (For this WebService, the XSLT did not generated automatically) which, I hope is not being applied properly in CPSC; but working fine outside of CPSC when I have checked the response XML with the XSLT in an online editor (http://www.freeformatter.com/xsl-transformer.html). Everything looks perfect in this editor where I have issues in CPSC.
I am getting a Transformation exception in CPSC and the response message was unable to convert into the nsXML. The exception I am receiving is below. Not sure whether it is due to the namespace or something else..
Note: I am having this issue in this Agent/WebService alone. I have tested with couple other WebServices where I didn't have any issues in getting the response and update the field in CPSC form successfully. So, I believe that there are no issues in the parser in our server.
Exception Received:
org.xml.sax.SAXParseException: Premature end of file. at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124) at com.newscale.bfw.util.XMLValidator.validate(XMLValidator.java:147) at com.newscale.is.core.MessageExecutor.processNSTaskTransportMessage(MessageExecutor.java:135) at com.newscale.is.core.MessageExecutor.processTransportMessage(MessageExecutor.java:431) at com.newscale.is.core.MessageExecutor.processSynchronousOutboundMessage(MessageExecutor.java:526) at com.newscale.is.adk.OutboundAdapterUtil.processSynchronousResponse(OutboundAdapterUtil.java:44) at com.newscale.is.adapter.http.HTTPOutboundAdapter.call(HTTPOutboundAdapter.java:190) at com.newscale.is.adapter.http.HTTPOutboundAdapter.processMessage(HTTPOutboundAdapter.java:147) at com.newscale.is.core.MessageRouter.routeMessage(MessageRouter.java:115) at com.newscale.is.core.MessageExecutor.processOutboundMessage(MessageExecutor.java:604) at com.newscale.is.core.MessageExecutor.processMessage(MessageExecutor.java:125) at com.newscale.is.core.QueueListener.handleTextMessage(QueueListener.java:91) at sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:340) at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:237) at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:168) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99) at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:73) at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:101) at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71) at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:115) at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:285) at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:322) at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:213) at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303) at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150) at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86) at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:105) at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:561) at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:499) at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325) at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1059) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1051) at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:948) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)
Sample XML File received as response from the WebService – which then wrapped with the <message> tag along with appropriate channel-id.
<message channel-id="10a60e45-65d4-40c0-826f-1a91d2135da0">
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ns:ITSPResponse xmlns:ns="urn:PegaRULES:SOAP:BNYMDataITSPTest:Services">
<Output>Test IT Service Portal - 1</Output>
</ns:ITSPResponse>
</soap:Body>
</soap:Envelope>
</message>
XSL Transformation
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" xmlns:ns="urn:PegaRULES:SOAP:BNYMDataITSPTest:Services">
<xsl:template match="/">
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="urn:PegaRULES:SOAP:BNYMDataITSPTest:Services">
<message>
<xsl:attribute name="channel-id">
<xsl:value-of select="//@*[local-name()='channel-id']" />
</xsl:attribute>
<send-parameters>
<agent-parameter>
<name>Output</name>
<value> <xsl:value-of select="//*[local-name()='Output']" /> </value>
</agent-parameter>
</send-parameters>
</message>
</xsl:template>
</xsl:stylesheet>The reply I got from Cisco Engineering team for this is to get the response as a soap message than XML data.
The tag should not be available in the response received. If we don't have this, the response will still consider as a valid XML / Soap message after wrapped by the tag.
If we have the tag in the response, after wrapping the tag, the format of the response will not be in good format.
Also, Cisco Engineering team has confirmed that it is not possible to remove the tag from CPSC. It should be removed by the WebService providers while sending the response.
For my case, I am consuming the WebService from a tool similar to CPSC where the entire settings has to be changed to send the response format as soap message than XML. So, we need to have another WebService as a middleware! Bad day! -
Factory.newDocumentBuilder().parse returning DeferredDocumentImpl in servle
With respect to my earlier postregarding servlet not able to print
xml document
In Document parseXMLFile(String filename, boolean b) in servlet the line factory.newDocumentBuilder().parse(new File(filename)); is returning DeferredDocumentImpl
but the same method containing
factory.newDocumentBuilder().parse(new File(filename)); is returning XmlDocument in pain java program
why is the behaviour different
Iam able to print the elements in plain java program but in servlet if i use the same method
iam not able to print anything and returned type
is different and root element iam seeing as nul
could anybody please help
thanks
BHanuDid the suggestion in http://swforum.sun.com/jive/thread.jspa?threadID=64634 not help?
(That is 'factory.setAttribute("http://apache.org/xml/features/dom/defer-node-expansion", (false));') -
Non-English characters processed correctly by XML Parser 2 XSLT?
I'm trying to transform an XML document (parsed as an XMLDocmument) using an XSL stylesheet (parsed as an XSLStylesheet) and the XSLProcessor class in Java, I encounter the following problem:
Non-US characters such as German umlauts, stored in the XML in &#xxx; style, are not processed properly. "|" (ü), for example, comes out as "C<". Is this a bug in the XSLProcessor class or am I doing something wrong? I'm using this stylesheet declaration:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml1/strict"> Or should I mess with the encoding attribute of the ?xml ...? PI?
tia
John SmithI have not specified any encoding.
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="completeproduct.xsl"?>
<PRODUCT connection="demosample" xmlns:xsql="urn:oracle-xsql">
<xsql:query>
select * from products
</xsql:query>
should i specify encoding
null -
I'm writting a session EJB that's passed a param (String query) which is supposed
to be any valid "query" string passed to the cm:select tag (see "http://edocs.bea.com/wlcs/docs31/p13ndev/jsptags.htm#1057716"
for more info on this tag and the query param).
My problem is this: I don't think I should write ALL the stuff to validate and
parse this string because bea has already done it in: com.beasys.commerce.foundation.expression.*;
but the only source of documentation available on those classes is the Javadoc(which
isn't that complete). Has anyone used these classes before(Search, Expression,
Criteria, Logical)? Does anyone know of some documents on how to use them?
Please help if you can. I'd really appreciate it. Thanks.rajan please just google or search SDN. there are large number of post for this..
to give you a head start: for using a particular index in the select query a %_HINTS ORACLE 'INDEX clause is added -
Error when starting parser: timeout during allocate / CPIC-CALL:'TfSAPCMRC'
Hello experts.
When I try to preview or refresh a Crystal Report document built on a BEx query I get the following error msg:
Database connector error: BAPI Error #0. Error when starting parser: timeout during allocate / CPIC-CALL: 'TfSAPCMRCV'.
We have done as suggested in "SAP Note 1032461 - MDX parser does not start", but without success.
This is what we've tried so far:
replaced the file "librfc32.dll" (in C:\Windows\System32 and C:\Windows\SysWOW64) with the new version mentioned in Note 413708.
tested the connection in SM59 - non successful
tested the report query with transaction MDXTEST - non successful
tried to start the mdxparser manually on server - non succesful, error msg: "The application failed to initialise.."
We have the following config:
MS server 2003 SP2 x64 ed.
SAP logon 7.20
MS SQL server 2005
CR 2008
new librfc32.dll version 7200.1.39.6461
Any ideas on what to try next would be highly appreciated!
Cheers, IngAHi Ingo.
We have only one application server.
I registered the new version of the file C:\windows\SysWOW64\librfc32.dll with regsvr32.exe successfully. I've also tried to copy the new file to the same directory as the mdxsvr.exe-file is located, but it made no difference.
Should I remove all other copies of librfc32.dll and only keep the one in folder C:\Windows\SysWOW64, or maybe register them all with regsvr32.exe?
--IngA
Edited by: Ingeborg Andreassen on Nov 5, 2010 10:36 AM -
Can not parse the xml in orion server.
Hi, can anyone help me on this.
I have some configuration file which should be parsed when start the server. It works fine in tomcat , JRun, and some other server, now when I test it using the orion server, It throws out the
org.apache.commons.digester.xmlrules.XmlLoadException: Relative URI "digester-rules.dtd"; can not be resolved without a document URI.
I put the dtd and xml together in web-root and specify the location using
<!DOCTYPE digester-rules PUBLIC "-//Jakarta Apache //DTD digester-rules XML V1.0//EN" "digester-rules.dtd">
can anyone tell me how to resolve this.
following is a code snippet of init the digester
Digester ruleDigester = new Digester();
ruleDigester.setUseContextClassLoader(true);
System.out.println(ruleURL);
FromXmlRuleSet ruleSet = new FromXmlRuleSet(ruleURL, ruleDigester);
Digester digester = new Digester();
digester.setUseContextClassLoader(true);
ruleSet.addRuleInstances(digester);
rules = digester.getRules();I think you'd better ask this question in apache user mailing list
http://jakarta.apache.org/site/mail2.html#Commons -
How can I take the part that parses the .XML file and make it a procedure.
CREATE OR REPLACE PACKAGE BODY XMLSTUD6 AS
Author: Jimmy Harris
Created: 5/25/2006
Purpose: 1.This package has an XML file initialized to a variable called DOC .
2.It will then take the values from the XML file and insert them into a PL/SQL table.
3.From the PL/SQL table it will insert values into the STUDENTS table.
4.After step four above, the STUDLOAD procedure will insert (Sequence,Status, .XML file, USER, SYSDATE, ERROR_Message
into the AUDIT_XMLSTUD table regardless if insert status was successfull or not status is indicated by either an Y or
NO and the original XML filed that was currently processed, the date and user who executed the procedure.
If the status was NO then it will insert the Oracle SQLERRM massage, into the REASON_FOR_ERROR column.
If status is Y then REASOK_FOR_ERROR IS NULL.
5,Make sure you embed the xml file with an inner and outer ' ' ie: ' the whole .xml file string ' as the input
parameter into the STUDLOAD procedure.
This package excepts the whole .XML file as a CLOB as an input parameter, so that the end-user will not have
modify the code.
Modification History: 1.6/09/2006 JImmy Harris Modified code, added the Function "WORD_CONVERTER1" to accept the requested text data and
return a coded value back to our Welligent system.
2. Was advised that a front end type of functionality was not neccesary for this issue so I removed the INSERT_XML_FILE,
UPDATE_XML_FILE and the INSERT_XML_file.
FUNCTION WORD_CONVERTER1 (v_domain IN VARCHAR2 := null,
v_incoming IN VARCHAR2 := null) RETURN VARCHAR2 IS
v_well VARCHAR2(32);
v_editdd BOOLEAN;
v_code VARCHAR2(32);
CURSOR C_conv_wrd IS
SELECT WELL
INTO v_code
FROM CONVERSION_TABLE
WHERE DOMAIN = UPPER(TRIM(v_domain))
AND INCOMING = UPPER(TRIM(v_incoming));
BEGIN
OPEN c_conv_wrd;
LOOP
FETCH c_conv_wrd INTO v_code;
EXIT WHEN c_conv_wrd%NOTFOUND;
END LOOP;
CLOSE c_conv_wrd;
RETURN v_code;
END WORD_CONVERTER1;
PROCEDURE STUDLOAD (DOC CLOB) IS
v_parser xmlparser.Parser;
v_doc xmldom.DOMDocument;
v_nl xmldom.DOMNodeList;
v_n xmldom.DOMNode;
v_mm NUMBER;
v_dd NUMBER;
v_yyyy NUMBER;
v_DATE DATE;
v_race VARCHAR2(1);
v_eth VARCHAR2(1);
v_prim_lang VARCHAR2(1);
v_house_lang VARCHAR2(1);
v_gender VARCHAR2(1);
TYPE stuxml_type IS TABLE OF STUDENTS%ROWTYPE;
s_tab stuxml_type := stuxml_type();
v_success VARCHAR2(200);
v_failure VARCHAR2(200);
l_error_code varchar2(200);
BEGIN
-- Create a parser.
v_parser := xmlparser.newParser;
xmlparser.setValidationMode(v_parser, FALSE);
-- Parse the document and create a new DOM document.
SYS.XMLPARSER.PARSECLOB ( v_parser, DOC );
v_doc := SYS.XMLPARSER.getDocument(v_parser);
-- Free resources associated with the Parser now it is no longer needed.
xmlparser.freeParser(v_parser);
-- Get a list of all the STUD nodes in the document using the XPATH syntax.
v_nl := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent');
-- Loop through the list and create a new record in a table collection for each STUD record.
FOR stud IN 0 .. xmldom.getLength(v_nl) - 1 LOOP
v_n := xmldom.item(v_nl, stud);
s_tab.extend;
-- Use XPATH syntax to assign values to he elements of the collection.
s_tab(s_tab.last).STUDENT_LAST_NAME :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/LastName');
s_tab(s_tab.last).STUDENT_FIRST_NAME :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/FirstName');
s_tab(s_tab.last).STUDENT_MI :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/MiddleName');
v_dd := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Day');
v_mm := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Month');
v_yyyy := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Year');
v_DATE := TO_DATE(v_mm||' '||v_dd||' '||v_yyyy,'MMDDYYYY');
s_tab(s_tab.last).STUDENT_DOB := v_date;
s_tab(s_tab.last).STUDENT_STREET :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/Street');
s_tab(s_tab.last).STUDENT_APART_NO :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/ApartmentNumber');
s_tab(s_tab.last).STUDENT_COUNTY :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/County');
s_tab(s_tab.last).STUDENT_STATE :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/State');
s_tab(s_tab.last).STUDENT_ZIP :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/ZipCode');
v_race := WORD_CONVERTER1('RACE',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Race')));
v_eth := WORD_CONVERTER1('EHTNICITY',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Ethnicity')));
v_prim_lang:= WORD_CONVERTER1('PRIMARY_LANG',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/PrimaryLanguage')));
v_house_lang:= WORD_CONVERTER1('SECONDARY_LANG',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/HouseholdLanguage')));
v_gender := WORD_CONVERTER1('GENDER',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Gender')));
s_tab(s_tab.last).STUDENT_RACE := v_race;
s_tab(s_tab.last).STUDENT_ETHNIC := v_eth;
s_tab(s_tab.last).STUDENT_PRI_LANG :=v_prim_lang;
s_tab(s_tab.last).STUDENT_SEC_LANG := v_house_lang;
s_tab(s_tab.last).STUDENT_GENDER :=v_gender;
END LOOP;
FOR stud IN s_tab.first..s_tab.last LOOP
INSERT INTO STUDENTS (SHISID, SSN, DOE_SCHOOL_NUMBER,PATIENT_TYPE, TEACHER, HOMEROOM,STUDENT_LAST_NAME, STUDENT_FIRST_NAME, STUDENT_MI,STUDENT_DOB,
STUDENT_BIRTH_CERT, STUDENT_COMM,STUDENT_MUSA, STUDENT_FAMSIZE, STUDENT_FAMINCOME,STUDENT_UNINSURED, STUDENT_LUNCH, STUDENT_ZIP,STUDENT_STATE,
STUDENT_COUNTY, STUDENT_STREET,STUDENT_APART_NO, STUDENT_PHONE, STUDENT_H2O_TYPE,STUDENT_WASTE_TRT, STUDENT_HOME_SET, STUDENT_NONHOME_SET,
STUDENT_GENDER, STUDENT_RACE, STUDENT_ETHNIC,STUDENT_PRI_LANG, STUDENT_SEC_LANG, STUDENT_ATRISK,EMER_COND_MEMO, ASSIST_DEVICE_TYPE,
SCHOOL_ENTER_AGE,STUDENT_CURR_GRADE, S504_ELIG_DATE, S504_DEV_DATE,S504_REV_DATE, STUDENT_504, STUDENT_IEP,IEP_EXP_DATE, GRAD_CLASS, TYPE_DIPLOMA,
GRADE_RETAIN, LIT_PASS_TEST_MATH, LIT_PASS_DATE_MATH,LIT_PASS_TEST_WRITE, LIT_PASS_DATE_WRITE, LIT_PASS_TEST_READ,LIT_PASS_DATE_READ, SPEC_ED_ELIG,
SPEC_ED_CODE,TRANSPORT_CODE, TRANSPORT_NO, PRIME_HANDICAP,PRIME_HANDICAP_PERCENT, PRIME_HANDI_MANAGER, FIRST_ADD_HANDI,FIRST_ADD_HANDICAP_PERCENT,
FIRST_ADD_HANDI_504, FIRST_ADD_HANDI_504_DATE, SECOND_ADD_HANDI, SECOND_ADD_HANDICAP_PERCENT, MED_EXTERNAL_NAME, INS_TYPE, INS_PRI, INS_NAME,
INS_MEDICAID_NO, ELIGDATE, INS_PRIV_INSURANCE, INS_APPR_BILL, INS_APPR_DATE, INS_PARENT_APPR,INS_POL_NAME, INS_POL_NO, INS_CARRIER_NO,
INS_CARRIER_NAME, INS_CARRIER_RELATE, INS_AFFECT_DATE, INS_COPAY_OV, INS_COPAY_RX, INS_COPAY_AMBUL,INS_COPAY_EMER, INS_COPAY_OUTPAT,STUDENT_INACTIVE,
PHYS_ID, ENCOUNTERNUM,USERID,MODDATE, STUDENT_ID, S504_DISABILITY,CHAPTER1, WELLNESS_ENROLL, SCHOOL_OF_RESIDENCE,INITIAL_IEP_DATE, CALENDAR_TRACK,
USA_BORN,ALT_ID, FUTURE_SCHOOL, IEP_LAST_MEETING,IEP_LAST_SETTING, IEP_LAST_REFER_EVAL, THIRD_ADD_HANDI,LEP, GIFTED, IEP_EXIT_REASON,
CASE_MANAGER_ID, INTAKE_NOTES, CALLER_PHONE,CALL_DATE, CALLER_RELATIONSHIP, CALLER_NAME,BUSINESS_PHONE, FAX, EMAIL,HIGHEST_EDUCATION, INTAKE_DATE,
SERVICE_COORDINATOR, DISCHARGE_DATE, DISCHARGE_REASON, DISCHARGE_NOTES,INTAKE_BY, INTAKE_STATUS, IEP_LAST_SERVED_DATE,IEP_APC_DATE, IEP_EXIT_DATE,
ADDRESS2, LEGAL_STATUS, RELIGION, EMPLOYMENT_STATUS, TARG_POP_GROUP1, TARG_POP_GROUP2, MARITAL_STATUS,THIRD_ADD_HANDI_PERCENT, LAST_INTERFACE_DATE,
SERVICE_PLAN_TYPE,CURRENT_JURISDICTION, FIPS, BIRTH_PLACE_JURISDICTION,BIRTH_PLACE_HOSPITAL, BIRTH_PLACE_STATE, BIRTH_PLACE_COUNTRY,
OTHER_CLIENT_NAME, SIBLINGS_WITH_SERVICES, PERM_SHARE_INFORMATION,PERM_VERIFY_INSURANCE, REFERRING_AGENCY, REFERRING_INDIVIDUAL,AUTOMATIC_ELIGIBILITY,
INTAKE_IEP_ID, FUTURE_SCHOOL2,FUTURE_SCHOOL3, TRANSLATOR_NEEDED, TOTAL_CHILDREN_IN_HOME,REFERRED_BY, FAMILY_ID, SCREENING_CONSENT_FLAG,PICTURE_FILE,
DUAL_ENROLLED, DOE_SCHOOL_NUMBER2)
VALUES (123456789025, null,null ,null,null,null ,s_tab(stud).STUDENT_LAST_NAME,s_tab(stud).STUDENT_FIRST_NAME,s_tab(stud).STUDENT_MI,
s_tab(stud).STUDENT_DOB,null ,null,null ,null,null,null,null,s_tab(stud).STUDENT_ZIP,s_tab(stud).STUDENT_STATE ,s_tab(stud).STUDENT_COUNTY,
s_tab(stud).STUDENT_STREET,s_tab(stud).STUDENT_APART_NO,null,null,null ,null , null,
s_tab(stud).STUDENT_GENDER ,s_tab(stud).STUDENT_RACE , s_tab(stud).STUDENT_ETHNIC,
s_tab(stud).STUDENT_PRI_LANG ,s_tab(stud).STUDENT_SEC_LANG, null, null ,null , null,
null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null,
null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null,
null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null,
null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null,
null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null,
null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null ,null , null, null, null,null );
END LOOP;
INSERT INTO AUDIT_XMLSTUD1(XMLSTUDPK,USERID,XMLFILE,STATUS,REASON_FOR_ERROR,DATE_MODIFIED)
VALUES(SEQ_XMLSTUD1.NEXTVAL,USER,DOC,'Y',NULL,SYSDATE);
HTP.HTMLOPEN;
v_success:= 'The values from the .XML file have been successfully inserted into the STUDENTS table in the Oracle Database.';
htp.bold(v_success);
HTP.HTMLCLOSE;
COMMIT;
-- Free any resources associated with the document now it that it is no longer needed.
xmldom.freeDocument(v_doc);
EXCEPTION
WHEN OTHERS THEN
l_error_code := SQLERRM;
INSERT INTO AUDIT_XMLSTUD1(XMLSTUDPK,USERID,XMLFILE,STATUS,REASON_FOR_ERROR,DATE_MODIFIED)
VALUES(SEQ_XMLSTUD1.NEXTVAL,USER,nvl(DOC,TO_CLOB('No .XML file entered, user pressed button without entering correct information.')),'NO',l_error_code,SYSDATE);
HTP.HTMLOPEN;
v_failure:= 'The attempt made to insert files to the Student table has failed because,'||l_error_code;
htp.bold(v_failure);
HTP.HTMLCLOSE;
COMMIT;
END STUDLOAD;
PROCEDURE UPDSTUDLOAD (DOC CLOB) IS
v_parser xmlparser.Parser;
v_doc xmldom.DOMDocument;
v_nl xmldom.DOMNodeList;
v_n xmldom.DOMNode;
v_mm NUMBER;
v_dd NUMBER;
v_yyyy NUMBER;
v_DATE DATE;
v_race VARCHAR2(1);
v_eth VARCHAR2(1);
v_prim_lang VARCHAR2(1);
v_house_lang VARCHAR2(1);
v_gender VARCHAR2(1);
TYPE stuxml_type IS TABLE OF STUDENTS%ROWTYPE;
s_tab stuxml_type := stuxml_type();
v_success VARCHAR2(200);
v_failure VARCHAR2(200);
l_error_code varchar2(200);
BEGIN
-- Create a parser.
v_parser := xmlparser.newParser;
xmlparser.setValidationMode(v_parser, FALSE);
-- Parse the document and create a new DOM document.
SYS.XMLPARSER.PARSECLOB ( v_parser, DOC );
v_doc := SYS.XMLPARSER.getDocument(v_parser);
-- Free resources associated with the Parser now it is no longer needed.
xmlparser.freeParser(v_parser);
-- Get a list of all the STUD nodes in the document using the XPATH syntax.
v_nl := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent');
-- Loop through the list and create a new record in a table collection for each STUD record.
FOR stud IN 0 .. xmldom.getLength(v_nl) - 1 LOOP
v_n := xmldom.item(v_nl, stud);
s_tab.extend;
-- Use XPATH syntax to assign values to he elements of the collection.
s_tab(s_tab.last).STUDENT_LAST_NAME :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/LastName');
s_tab(s_tab.last).STUDENT_FIRST_NAME :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/FirstName');
s_tab(s_tab.last).STUDENT_MI :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/MiddleName');
v_dd := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Day');
v_mm := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Month');
v_yyyy := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Year');
v_DATE := TO_DATE(v_mm||' '||v_dd||' '||v_yyyy,'MMDDYYYY');
s_tab(s_tab.last).STUDENT_DOB := v_date;
s_tab(s_tab.last).STUDENT_STREET :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/Street');
s_tab(s_tab.last).STUDENT_APART_NO :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/ApartmentNumber');
s_tab(s_tab.last).STUDENT_COUNTY :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/County');
s_tab(s_tab.last).STUDENT_STATE :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/State');
s_tab(s_tab.last).STUDENT_ZIP :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/ZipCode');
v_race := WORD_CONVERTER1('RACE',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Race')));
v_eth := WORD_CONVERTER1('EHTNICITY',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Ethnicity')));
v_prim_lang:= WORD_CONVERTER1('PRIMARY_LANG',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/PrimaryLanguage')));
v_house_lang:= WORD_CONVERTER1('SECONDARY_LANG',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/HouseholdLanguage')));
v_gender := WORD_CONVERTER1('GENDER',UPPER(xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Gender')));
s_tab(s_tab.last).STUDENT_RACE := v_race;
s_tab(s_tab.last).STUDENT_ETHNIC := v_eth;
s_tab(s_tab.last).STUDENT_PRI_LANG :=v_prim_lang;
s_tab(s_tab.last).STUDENT_SEC_LANG := v_house_lang;
s_tab(s_tab.last).STUDENT_GENDER :=v_gender;
END LOOP;
FOR stud IN s_tab.first..s_tab.last LOOP
UPDATE STUDENTS
SET
STUDENT_LAST_NAME = s_tab(stud).STUDENT_LAST_NAME,
STUDENT_FIRST_NAME = s_tab(stud).STUDENT_FIRST_NAME,
STUDENT_MI = s_tab(stud).STUDENT_MI,
STUDENT_DOB = s_tab(stud).STUDENT_DOB,
STUDENT_ZIP = s_tab(stud).STUDENT_ZIP,
STUDENT_STATE = s_tab(stud).STUDENT_STATE,
STUDENT_COUNTY = s_tab(stud).STUDENT_COUNTY,
STUDENT_STREET = s_tab(stud).STUDENT_STREET,
STUDENT_APART_NO = s_tab(stud).STUDENT_APART_NO
WHERE SHISID = 123456789025;
END LOOP;
INSERT INTO AUDIT_XMLSTUD1(XMLSTUDPK,USERID,XMLFILE,STATUS,REASON_FOR_ERROR,DATE_MODIFIED)
VALUES(SEQ_XMLSTUD1.NEXTVAL,USER,DOC,'Y',NULL,SYSDATE);
HTP.HTMLOPEN;
v_success:= 'The updated .XML file has been successfully saved to the STUDENTS table in the Oracle Database.';
htp.bold(v_success);
HTP.HTMLCLOSE;
COMMIT;
-- Free any resources associated with the document now it that it is no longer needed.
xmldom.freeDocument(v_doc);
EXCEPTION
WHEN OTHERS THEN
l_error_code := SQLERRM;
INSERT INTO AUDIT_XMLSTUD1(XMLSTUDPK,USERID,XMLFILE,STATUS,REASON_FOR_ERROR,DATE_MODIFIED)
VALUES(SEQ_XMLSTUD1.NEXTVAL,USER,nvl(DOC,TO_CLOB('No .XML file entered, user pressed button without entering correct information.')),'NO',l_error_code,SYSDATE);
HTP.HTMLOPEN;
v_failure:= 'The attempt made to insert files to the Student table has failed because,'||l_error_code;
htp.bold(v_failure);
HTP.HTMLCLOSE;
COMMIT;
END UPDSTUDLOAD;
PROCEDURE DELSTUDLOAD (DOC CLOB) IS
v_parser xmlparser.Parser;
v_doc xmldom.DOMDocument;
v_nl xmldom.DOMNodeList;
v_n xmldom.DOMNode;
v_mm NUMBER;
v_dd NUMBER;
v_yyyy NUMBER;
v_DATE DATE;
TYPE stuxml_type IS TABLE OF STUDENTS%ROWTYPE;
s_tab stuxml_type := stuxml_type();
v_success VARCHAR2(200);
v_failure VARCHAR2(200);
l_error_code varchar2(200);
BEGIN
-- Create a parser.
v_parser := xmlparser.newParser;
xmlparser.setValidationMode(v_parser, FALSE);
-- Parse the document and create a new DOM document.
SYS.XMLPARSER.PARSECLOB ( v_parser, DOC );
v_doc := SYS.XMLPARSER.getDocument(v_parser);
-- Free resources associated with the Parser now it is no longer needed.
xmlparser.freeParser(v_parser);
-- Get a list of all the STUD nodes in the document using the XPATH syntax.
v_nl := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent');
-- Loop through the list and create a new record in a table collection for each STUD record.
FOR stud IN 0 .. xmldom.getLength(v_nl) - 1 LOOP
v_n := xmldom.item(v_nl, stud);
s_tab.extend;
-- Use XPATH syntax to assign values to he elements of the collection.
s_tab(s_tab.last).STUDENT_LAST_NAME :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/LastName');
s_tab(s_tab.last).STUDENT_FIRST_NAME :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/FirstName');
s_tab(s_tab.last).STUDENT_MI :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Name/MiddleName');
v_dd := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Day');
v_mm := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Month');
v_yyyy := xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/BirthDate/Year');
v_DATE := TO_DATE(v_mm||' '||v_dd||' '||v_yyyy,'MMDDYYYY');
s_tab(s_tab.last).STUDENT_DOB := v_date;
s_tab(s_tab.last).STUDENT_STREET :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/Street');
s_tab(s_tab.last).STUDENT_APART_NO :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/ApartmentNumber');
s_tab(s_tab.last).STUDENT_COUNTY :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/County');
s_tab(s_tab.last).STUDENT_STATE :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/State');
s_tab(s_tab.last).STUDENT_ZIP :=xslprocessor.valueOf(v_n,'/com.welligent.Student.BasicStudent.Create/DataArea/NewData/BasicStudent/Address/ZipCode');
END LOOP;
FOR stud IN s_tab.first..s_tab.last LOOP
DELETE FROM STUDENTS
WHERE SHISID = 123456789025;
END LOOP;
INSERT INTO AUDIT_XMLSTUD1(XMLSTUDPK,USERID,XMLFILE,STATUS,REASON_FOR_ERROR,DATE_MODIFIED)
VALUES(SEQ_XMLSTUD1.NEXTVAL,USER,DOC,'Y',NULL,SYSDATE);
HTP.HTMLOPEN;
v_success:= 'The .XML file has been successfully deleted from the STUDENTS table in the Oracle Database.';
htp.bold(v_success);
HTP.HTMLCLOSE;
COMMIT;
-- Free any resources associated with the document now it that it is no longer needed.
xmldom.freeDocument(v_doc);
EXCEPTION
WHEN OTHERS THEN
l_error_code := SQLERRM;
INSERT INTO AUDIT_XMLSTUD1(XMLSTUDPK,USERID,XMLFILE,STATUS,REASON_FOR_ERROR,DATE_MODIFIED)
VALUES(SEQ_XMLSTUD1.NEXTVAL,USER,nvl(DOC,TO_CLOB('No .XML file entered, user pressed button without entering correct information.')),'NO',l_error_code,SYSDATE);
HTP.HTMLOPEN;
v_failure:= 'The attempt made to insert files to the Student table has failed because,'||l_error_code;
htp.bold(v_failure);
HTP.HTMLCLOSE;
COMMIT;
END DELSTUDLOAD;
END XMLSTUD6;Try opening the problem files using a text editor or file viewer to see what the first few bytes contain. All valid FM binary files for FM 11 will contain <MakerFile 11.0> in the first bytes of the file.
When updating books, it's sometimes better to just to create a new book file and add the files to that.
When renaming files in a book, changes at the system level will break any links/cross-references between files, so it's always best to use the Rename option in the Book file to change FM file names. This will maintain the correct linkages. -
Parsing XML file & insert into Oracle Tables
Hi,
Following is a sample xml file which is an input for a oracle procedure :
<Sales ID="1" CreatedDate="16-Jan-2007" CreatedTime="16:09:40">
<Customer ID="1" Name="Scott" Address="City1">
<Order ID="1" Date="15-Jan-2007" TotItems="2" Value="200">
<Item ID="01" Name="Chocolate" Qty="2" Amount="80" />
<Item ID="03" Name="Biscuit" Qty="5" Amount="120" />
</Order>
</Customer>
<Customer ID="2" Name="Tiger" Address="City2">
<Order ID="1" Date="15-Jan-2007" TotItems="1" Value="500">
<Item ID="01" Name="Pizza" Qty="3" Amount="500" />
</Order>
</Customer>
<User ID="ABC" Name="TestUser" LastLogin="16-Jan-2007" />
<City Code="NY" Name="New York" />
<City Code="NJ" Name="New Jersy" />
</Sales>
I have individual tables for Sales, Customer, Order, Item, User & City tags with proper referential constraints. I have to parse the xml & have to insert the corresponsing tables for each & every tag if the ID in individual tag does not exists in the table. If the ID already exist, then, I have to update other attributes in the table for the corresponding ID.
Can anyone suggest me the simplest way to perform the above said scenario?Dera Michael,
Sorry for the confusing previous reply. I went through your solution again and tried for my XML File.
I have stored the XML File in table XXLF_DS_XML.Should I make use of the table in the below query.
Here is my SQL Query erroring Out
SQL> SELECT EXTRACTVALUE(s.COLUMN_VALUE,
2 '/Header@orderID') ID
3 ,EXTRACTVALUE(c.COLUMN_VALUE,
4 '/Detail@lineNumber') lienum
5 ,EXTRACTVALUE(t.COLUMN_VALUE,
6 '/Detail/Tax@currency') currency
7 ,EXTRACTVALUE(t.COLUMN_VALUE,
8 '/Detail/Tax/Money') customer_name
9 FROM TABLE(XMLSEQUENCE(EXTRACT(XMLTYPE('- <Recordset>
10 - <Header dueDate="2007-01-17T16:09:05" orderDate="2004-01-17" orderID="0009" transactionID="1389"
type="new">
11 <KeyIndex>2</KeyIndex>
12 - <BillTo>
13 - <Address addressID="5619" isoCountryCode="US">
14 <Name>fMat</Name>
15 - <PostalAddress name="default">
16 <Street>34545</Street>
17 <City>dfgfg</City>
18 <State>AZ</State>
19 <PostalCode>85086-1693</PostalCode>
20 <County>Maricopa</County>
21 <Country>US</Country>
22 </PostalAddress>
23 <Email name="default">[email protected]</Email>
24 </Address>
25 </BillTo>
26 <PromotionCode />
27 - <SubTotal>
28 <Money currency="USD">32.49</Money>
29 </SubTotal>
30 - <Tax>
31 <Money currency="USD">2.32</Money>
32 <Description />
33 </Tax>
34 - <Shipping>
35 <Money currency="USD">8.95</Money>
36 <Description />
37 </Shipping>
38 </Header>
39 - <Detail lineNumber="1" quantity="1">
40 - <ItemDetail>
41 - <UnitPrice>
42 <Money currency="USD">29.99</Money>
43 </UnitPrice>
44 <ShortName>Little;reg; pxxxx® Learning System</ShortName>
45 </ItemDetail>
46 - <Tax>
47 <Money currency="USD">1.68</Money>
48 <Description />
49 - <TaxDetail category="sales">
50 - <TaxAmount>
51 <Money currency="USD">1.68</Money>
52 </TaxAmount>
53 <TaxLocation>AZ</TaxLocation>
54 </TaxDetail>
55 </Tax>
56 </Detail>
57 - <Detail lineNumber="2" quantity="1">
58 - <ItemDetail>
59 - <UnitPrice>
60 <Money currency="USD">29.99</Money>
61 </UnitPrice>
62 <ShortName>Little;reg; pxxxx® Learning System</ShortName>
63 </ItemDetail>
64 - <Tax>
65 <Money currency="USD">1.68</Money>
66 <Description />
67 - <TaxDetail category="sales">
68 - <TaxAmount>
69 <Money currency="USD">1.68</Money>
70 </TaxAmount>
71 <TaxLocation>AZ</TaxLocation>
72 </TaxDetail>
73 </Tax>
74 - <Tax>
75 <Money currency="USD">0.68</Money>
76 <Description />
77 - <TaxDetail category="sales">
78 - <TaxAmount>
79 <Money currency="USD">0.68</Money>
80 </TaxAmount>
81 <TaxLocation>DISTRICT</TaxLocation>
82 </TaxDetail>
83 </Tax>
84 </Detail>
85 </Recordset>'),'/Recordset/Header'))) s
86 ,TABLE(XMLSEQUENCE(EXTRACT(c.COLUMN_VALUE,
87 '/Recordset/Detail'))) c
88 ,TABLE(XMLSEQUENCE(EXTRACT(t.COLUMN_VALUE,
89 '/Recordset/Detail/Tax'))) t
90 /
,TABLE(XMLSEQUENCE(EXTRACT(c.COLUMN_VALUE,
ERROR at line 86:
ORA-00904: "C"."COLUMN_VALUE": invalid identifier
Here is my XML Data
<Recordset>
<Header dueDate="2007-01-17T16:09:05" orderDate="2004-01-17" orderID="0009" transactionID="1389"
type="new">
<KeyIndex>2</KeyIndex>
<BillTo>
<Address addressID="5619" isoCountryCode="US">
<Name>fMat</Name>
<PostalAddress name="default">
<Street>34545 </Street>
<City>dfgfg</City>
<State>AZ</State>
<PostalCode>85086-1693</PostalCode>
<County>Maricopa</County>
<Country>US</Country>
</PostalAddress>
<Email name="default">[email protected]</Email>
</Address>
</BillTo>
<PromotionCode/>
<SubTotal>
<Money currency="USD">32.49</Money>
</SubTotal>
<Tax>
<Money currency="USD">2.32</Money>
<Description/>
</Tax>
<Shipping>
<Money currency="USD">8.95</Money>
<Description/>
</Shipping>
</Header>
<Detail lineNumber="1" quantity="1">
<ItemDetail>
<UnitPrice>
<Money currency="USD">29.99</Money>
</UnitPrice>
<ShortName>Little;reg; pxxxx® Learning System </ShortName>
</ItemDetail>
<Tax>
<Money currency="USD">1.68</Money>
<Description/>
<TaxDetail category="sales">
<TaxAmount>
<Money currency="USD">1.68</Money>
</TaxAmount>
<TaxLocation>AZ</TaxLocation>
</TaxDetail>
</Tax>
</Detail>
<Detail lineNumber="2" quantity="1">
<ItemDetail>
<UnitPrice>
<Money currency="USD">29.99</Money>
</UnitPrice>
<ShortName>Little;reg; pxxxx® Learning System </ShortName>
</ItemDetail>
<Tax>
<Money currency="USD">1.68</Money>
<Description/>
<TaxDetail category="sales">
<TaxAmount>
<Money currency="USD">1.68</Money>
</TaxAmount>
<TaxLocation>AZ</TaxLocation>
</TaxDetail>
</Tax>
<Tax>
<Money currency="USD">0.68</Money>
<Description/>
<TaxDetail category="sales">
<TaxAmount>
<Money currency="USD">0.68</Money>
</TaxAmount>
<TaxLocation>DISTRICT</TaxLocation>
</TaxDetail>
</Tax>
</Detail>
</Recordset>
Thanks -
XML Parse error while loading an XML file
HI Folks,
I was trying to load and XML file into BODS.. The XML file is well-formed and the same when tested in other tools is getting loaded without any issues..
I have created a XML-File format with the corresponding XSD..
But here in BODS it is giving - Parse error
1) when i try to view the data of the source XML in my dataflow ..it is giving "XML Parser Failed".. and not able to show data..
2) When I run my job i get the same pares error - with details as under..
---> Error here is "Unable to recognize element 'TAB' " or some time is say " Element TAB should be qualified"
Please guide with this if you have any info..thanks
I'm pasting the XML source file format here for your reference:--
<?xml version="1.0" encoding="iso-8859-1" ?>
- <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
- <asx:values>
- <TAB>
- <items>
+ <CUSTOMER_RECORD>
<CUSTOMER_NUMBER>1111111111</CUSTOMER_NUMBER>
<NAME_1>ABC</NAME_1>
<NAME_2>OFM/COMMERCIAL ACCOUNTS</NAME_2>
<STREET_1>31 CENTER DRIVE MCS2045</STREET_1>
<STREET_2 />
<CITY>BETHESDA</CITY>
<STATE_CODE>MD</STATE_CODE>
<POSTAL_CODE>20892-2045</POSTAL_CODE>
<COUNTRY_CODE>US</COUNTRY_CODE>
<ORDER_BLOCK />
<ERP_CREATE_DATE>20040610</ERP_CREATE_DATE>
<ERP_CREATED_BY>DGUPTA</ERP_CREATED_BY>
<ERP_MODIFY_DATE>20120201</ERP_MODIFY_DATE>
<ERP_MODIFIED_BY>LWOHLFEI</ERP_MODIFIED_BY>
<INDUSTRY_CODE>0103</INDUSTRY_CODE>
<ACCOUNT_GROUP_ID>0001</ACCOUNT_GROUP_ID>
<SALES_NOTE />
<ADDRESS_NOTE />
<CUSTOMER_CLASSIFICATION_CODE>02</CUSTOMER_CLASSIFICATION_CODE>
<GLN_NUMBER />
<PREVIOUS_ACCT_NO />
<ACCOUNT_TYPE />
<GAG />
<SDI_ID />
<HOSP_ID />
<HIN />
<DUNS />
<PO_BOX />
<POB_CITY />
<POB_ZIP />
<PHONE_NUMBER>77777</PHONE_NUMBER>
<EMAIL_DOMAIN />
<REQUESTER />
<ERP_SOURCE_SYSTEM>ECC</ERP_SOURCE_SYSTEM>
</CUSTOMER_RECORD>
- <SALES_ORG_DATA>
+ <item>
<CUSTOMER_NUMBER>1111111111</CUSTOMER_NUMBER>
<SALES_ORG>0130</SALES_ORG>
<CUSTOMER_GROUP>03</CUSTOMER_GROUP>
<ORDER_BLOCK_CODE />
<ERP_SOURCE_SYSTEM>ECC</ERP_SOURCE_SYSTEM>
</item>
+ <item>
<CUSTOMER_NUMBER>1111111111</CUSTOMER_NUMBER>
<SALES_ORG>0120</SALES_ORG>
<CUSTOMER_GROUP>11</CUSTOMER_GROUP>
<ORDER_BLOCK_CODE />
<ERP_SOURCE_SYSTEM>ECC</ERP_SOURCE_SYSTEM>
</item>
</SALES_ORG_DATA>
</items>
</TAB>
</asx:values>
</asx:abap>Pierre,
Depending on the object "myLastFile", the method openDlg might not even exist (if the myLastFile object is not a File object, for instance). And I do not see any need for the myLastFile anyhow, as you are presenting a dialog to select a file to open. I recommend using the global ChooseFile( ) method instead. This will give you a filename as string in full path notation, or null when no file was selected in the dialog. I am not sure what your ExtendScript documentation states about the return value for ChooseFile, but if that differs from what I am telling you here, the documentation is wrong. So, if you replace the first lines of your code with the following it should work:
function openXMLFile ( ) {
var filename = ChooseFile ( "Choose XML file ...", "", "*.xml", Constants.FV_ChooseSelect );
While writing this, I see that Russ has already given you the same advice. Use the symbolic constant value I indicated to use the ChooseFile dialog to select a single file (it can also be used to select a directory or open a file - but you want to control the opening process yourself). Note that this method allows you to set a start directory for the dialog (second parameter). The ESTK autocompletion also gives you a fifth parameter "helplink" which is undocumented and can safely be ignored.
Good luck
Jang -
How to pass the table name dynamically in xml parsing
Hi All,
I have created one procedure for parsing xml file which is working perfectly.
FORALL i IN t_tab.first .. t_tab.last
INSERT INTO Test_AP VALUES t_tab(i);Now I want to put the table name dynamically+. For that I have added one query and modify above code as follow:-
I have already declare dml_str varchar2(800) in declaration part.
Query is as follows:-
select table_name into tab_name from VERSION_DETAILS where SUBVERSION_NO=abc; -- here abc is variable name which contains values.
FORALL i IN t_tab.first .. t_tab.last
dml_str := 'INSERT INTO ' || tab_name || ' values :vals';
EXECUTE IMMEDIATE dml_str USING t_tab(i);But it's not working. How I will resolve this or through which way I achieved the intended results. Anyone can guide me on this matter.
Thanks in advance for your help...Hi,
But it's not working.Don't you think it would help to give the error message?
Put the assignment before FORALL.
FORALL only accepts one subsequent DML statement (static or dynamic SQL) :
dml_str := 'INSERT INTO ' || tab_name || ' values :vals';
FORALL i IN t_tab.first .. t_tab.last
EXECUTE IMMEDIATE dml_str USING t_tab(i);
Maybe you are looking for
-
Are different frame rate clips automatically conformed to that of the project?
I have a 25p project and have dropped in some clips shot at 30p. I thought I would have to conform those clips to play at 25p but they appear to be doing that already and to my surprise there is no orange render line above them. Is this correct and i
-
Torch will no longer sync with iMac
I had set it up to sync with my iMac. And it was working. But now it does no longer work and I do not know why or what has changed. I basically use my bbry calendar for everything and I have my iMac calendar which gets updates from my kids' schools'
-
How should NEF files from my D300 be dealt with?
I have a D300 and CS2. I have the CS2 version of Lightroom, PS and Bridge. I've been researching NEF files and their compatibility with the adobe applications I have. I'm confused on the best way to work with NEF files produced by the D300 directly w
-
Word for mac 2011 - jpeg images vanish when saved as pdf
The subject box pretty much explains the problem! I've tried ticking the 'drawing objects' box in preferences, and unchecking the 'image placeholders', but I still get pdfs with just a blank space where my word .docx has an image. help!
-
Where is Options - General in Firefox on Mac
I switched to Mac from a PC. Where is OPTIONS under Tools? There isn't PREFERENCES either.