How to validate inserted xml data in oracle is correct or not
(i.e.how to validate xml syntax and tags are correct)
XML data has been inserted in Oracle database.Once inserted
I want to validate that data entered and tags inserted are correct
or not.
Pl help
Some small remarks after a life time of write that small notepad.
Don't use XMLIsValid() - Apperently it was once ment for use in table constraints only AND the most annoying part, it doesn't give you a proper error message.
More usable is schemaValidate() - it throws a useful error message... I never came around to update that post or write a proper one while using schemaValidate().
I would be against advising / using a Java wrapper to achieve this goal unless you are on a pre 9.2 database version. Registering, validation and such is optimized (in memory) in Oracle from the beginning in 9.2.0.3 and onwards to avoid for instance reparsing of the XML Schema itself. If a XML Schema is registered a lot is optimized including DOM, which will be avoided and "outsmarted" by using XOB objects (see the Oracle manuals only a few hits and those will point you directly to the optimizations at hand).
Similar Messages
-
Steps to insert xml data into oracle
Please give me next steps to insert xml data into oracle 9i:
i've been doing this steps :
1. create folder in oracle port:8080
2. copy xsd into folder
3. register schema
4. Give me next step...
5.
6.
Thanksthis is my complete xmlschema
<?xml version = "1.0" encoding = "UTF-8"?>
<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema">
<xs:element name = "A3A8Vers" type = "xs:string"/>
<xs:element name = "F1F5Vers" type = "xs:string">
</xs:element>
<xs:element name = "sequence" type = "xs:string">
</xs:element>
<xs:element name = "amf" type = "xs:string">
</xs:element>
<xs:element name = "trnsKeyNumber" type = "xs:string">
</xs:element>
<xs:element name = "mac" type = "xs:string">
</xs:element>
<xs:element name = "encryptionKey" type = "xs:string">
</xs:element>
<xs:element name = "signature" type = "xs:string">
</xs:element>
<xs:element name = "signer">
<xs:complexType>
<xs:sequence>
<xs:element ref = "entityNumber"/>
<xs:element ref = "keyNumber"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name = "entityNumber" type = "xs:string">
</xs:element>
<xs:element name = "keyNumber" type = "xs:string">
</xs:element>
<xs:element name = "pblKey">
<xs:complexType>
<xs:sequence>
<xs:element ref = "entityNumber"/>
<xs:element ref = "entityRole"/>
<xs:element ref = "keyNumber"/>
<xs:element ref = "publicKeyVal"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name = "ntrTime" type = "xs:string">
</xs:element>
<xs:element name = "deActionTime" type = "xs:string">
</xs:element>
<xs:element name = "actionTime" type = "xs:string">
</xs:element>
<xs:element name = "entityRole">
<xs:complexType>
<xs:attribute name = "role" default = "INVALID">
<xs:simpleType>
<xs:restriction base = "xs:NMTOKEN">
<xs:enumeration value = "TKD"/>
<xs:enumeration value = "SKD"/>
<xs:enumeration value = "INVALID"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name = "publicKeyVal">
<xs:complexType>
<xs:sequence>
<xs:element ref = "exponent"/>
<xs:element ref = "mod"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name = "exponent" type = "xs:string">
</xs:element>
<xs:element name = "mod" type = "xs:string">
</xs:element>
<xs:element name = "encriptionTransKey" type = "xs:string">
</xs:element>
<xs:element name = "keyType" type = "xs:string">
</xs:element>
</xs:schema>.
I use command to create table :
create table elements of xmltype
xmlschema "http://192.168.1.1:8080/test.xsd"
element "publicKey"
. But why the result,table as object type. so i cant use command "desc <table_name>;" -
Insert XML data into oracle table
I want to insert xml data returned by the VB code into oracle table.
As a prequisite I have installed the XDK capabilities for Oracle by installing JServer & running
SQL scripts catxsu.sql,xmlparserv2.jar,load.sql to load the XMLSQL Utility (DBMS_XMLQuery) into the database.
I have also granted following privileges to the user.
Grant users access to XMLParser and XMLDom packages:
grant execute on xmldom to public;
grant execute on xmlparser to public;
create public synonym xmldom for sys.xmldom;
create public synonym xmlparser for sys.xmlparser;
But still i am not able to create procedure which will accept input parameter as an XML document coming from front end which in turn will insert that record into simple oracle table . I am using Oracle 8.1.7
Thanks in advanceWould you specify the database version?
Since DBMS_XMLSave requires DOM, you normally need to divide the huge XML before insertion. -
Complex transformation inserting xml data to oracle database.
Hi,
I Have one small Problem While loading xml data to a oracle database.
In the XSD i have the Columns Like this.
<Data>
<Type_Trs>
<T1>
<T2>
</Data>
My Database contains only two columns
For Example:
Type_Trs
Corr_Data.
Now My problem is Based on Type_Trs Value i need to take values of T1 and T2 should be loaded in Corr_Data column.
How to write Xsl transformation for this using <xsl:choose>.
For Clearing the Question I am giving the Example.
Case : 1
<Data>
<type_Trs>BO</Type_Trs>
<T1>1</T1>
<T2>2</T2>
</Data>
In the Example my type_trs is value 'BO', so the Data in table should be
Type_Trs Corr_Data
======= =======
BO 1
Case : 2
<Data>
<type_Trs>CP</Type_Trs>
<T1>1</T1>
<T2>2</T2>
</Data>
In the Example my type_trs is value 'CP', so the Data in table should be
Type_Trs Corr_Data
======= =======
CP 2
For doing this How can i write my XSL transformation based on the condition?
Thanks in advances
Regards
GSRWhy do you need a XSL transformation for this? Can you not get the results based on this select:
SQL> SELECT DISTINCT EXTRACTVALUE (t2.COLUMN_VALUE, 'Type_Trs') type_trs,
CASE EXTRACTVALUE (t2.COLUMN_VALUE, 'Type_Trs')
WHEN 'BO'
THEN EXTRACTVALUE (t3.COLUMN_VALUE, 'T1')
WHEN 'CP'
THEN EXTRACTVALUE (t4.COLUMN_VALUE, 'T2')
END corr_data
FROM TABLE
(XMLSEQUENCE
(EXTRACT
(XMLTYPE
('<Data>
<Type_Trs>BO</Type_Trs>
<T1>1</T1>
<T2>2</T2>
<Type_Trs>CP</Type_Trs>
<T1>1</T1>
<T2>2</T2>
</Data>'
'/Data'
) t1,
TABLE (XMLSEQUENCE (EXTRACT (t1.COLUMN_VALUE,
'/Data/Type_Trs')
) t2,
TABLE (XMLSEQUENCE (EXTRACT (t1.COLUMN_VALUE, '/Data/T1'))) t3,
TABLE (XMLSEQUENCE (EXTRACT (t1.COLUMN_VALUE, '/Data/T2'))) t4
TYPE_TRS CORR_DATA
CP 2
BO 1 -
How to Convert Normal XML date or Oracle date to JDE Julian Date
We can do a simple mathematical step in XSLT :
'xpath20:format-dateTime(xpath20:current-dateTime(),"[Y0001][d001]") - 1900000'
Or in SQL :
Select to_char(sysdate,'YYYYDDD')-1900000 from dual;
Julian Date is: Year in 4 digits, YYYY, and Number of days in 3 digits, DDD
JDE Julian Date is Julian Date -1900000 (ie it counts Julian date from 1900 Year)
"[Y0001][d001]” returns date in Year in 4 digit + number of days in 3 digits. This is the Julian date.
Subtracting 1900000 ( ie YR ’1900’ & DAY ‘000’) gives the required JDE Julian Date.
Edited by: prakash.pankaj on Jul 8, 2011 2:13 PM
Edited by: prakash.pankaj on Jul 8, 2011 4:02 PM
Edited by: panks on Jul 20, 2011 3:43 PMHi,
getTime() (in Date) will give you that date in milliseconds since January 1, 1970 00:00:00 GMT.
To my knowledege, this is the same as Unix date format. -
How to insert more than 32k xml data into oracle clob column
how to insert more than 32k xml data into oracle clob column.
xml data is coming from java front end
if we cannot use clob than what are the different options availableAre you facing any issue with my code?
String lateral size error will come when you try to insert the full xml in string format.
public static boolean writeCLOBData(String tableName, String id, String columnName, String strContents) throws DataAccessException{
boolean isUpdated = true;
Connection connection = null;
try {
connection = ConnectionManager.getConnection ();
//connection.setAutoCommit ( false );
PreparedStatement PREPARE_STATEMENT = null;
String sqlQuery = "UPDATE " + tableName + " SET " + columnName + " = ? WHERE ID =" + id;
PREPARE_STATEMENT = connection.prepareStatement ( sqlQuery );
// converting string to reader stream
Reader reader = new StringReader ( strContents );
PREPARE_STATEMENT.setClob ( 1, reader );
// return false after updating the clob data to DB
isUpdated = PREPARE_STATEMENT.execute ();
PREPARE_STATEMENT.close ();
} catch ( SQLException e ) {
e.printStackTrace ();
finally{
return isUpdated;
Try this JAVA code. -
How to store XML data into Oracle Table
I had trouble to store XML data into Oracle Table with XDK (Oracle 8.1.7 ). The error is:
C:\XDK_Java_9_2\xdk\demo\java\Test>java testInsert Dept.xml
<Line 1, Column 1>: XML-0108: (Fatal Error) Start of root element expected.
Exception in thread "main" oracle.xml.sql.OracleXMLSQLException: Start of root element expected.
at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2263)
at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1333)
at testInsert.main(testInsert.java:8)
Here is my xml file:
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DEPTNO>10</DEPTNO>
<DNAME>ACCOUNTING</DNAME>
<LOC>NEW YORK</LOC>
</ROW>
<ROW num="2">
<DEPTNO>20</DEPTNO>
<DNAME>RESEARCH</DNAME>
<LOC>DALLAS</LOC>
</ROW>
<ROW num="3">
<DEPTNO>30</DEPTNO>
<DNAME>SALES</DNAME>
<LOC>CHICAGO</LOC>
</ROW>
<ROW num="4">
<DEPTNO>40</DEPTNO>
<DNAME>OPERATIONS</DNAME>
<LOC>BOSTON</LOC>
</ROW>
</ROWSET>
and here is structure of table:
Name Null? Type
DEPTNO NOT NULL NUMBER(2)
DNAME VARCHAR2(14)
LOC VARCHAR2(13)
and here is my Java Code:
import java.sql.*;
import oracle.xml.sql.dml.OracleXMLSave;
public class testInsert{
public static void main(String[] args) throws SQLException{
Connection conn = getConnection();
OracleXMLSave sav = new OracleXMLSave(conn,"scott.tmp_dept");
sav.insertXML(args[0]);
sav.close();
conn.close();
private static Connection getConnection()throws SQLException{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@amt-ebdev01:1521:mydept","scott","tiger");
return conn;
Could you help me ? Thanks !The problem is that you need to pass avalid URL , Document...
Please try this code instead:
import java.net.*;
import java.sql.*;
import java.io.*;
import oracle.xml.sql.dml.OracleXMLSave;
public class testInsert
public static void main(String[] args) throws SQLException{
Connection conn = getConnection();
OracleXMLSave sav = new OracleXMLSave(conn,"scott.temp_dept");
URL url = createURL(args[0]);
sav.insertXML(url);
sav.close();
conn.close();
private static Connection getConnection()throws SQLException{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@dlsun1982:1521:jwxdk9i","scott","tiger");
return conn;
// Helper method to create a URL from a file name
static URL createURL(String fileName)
URL url = null;
try
url = new URL(fileName);
catch (MalformedURLException ex)
File f = new File(fileName);
try
String path = f.getAbsolutePath();
// This is a bunch of weird code that is required to
// make a valid URL on the Windows platform, due
// to inconsistencies in what getAbsolutePath returns.
String fs = System.getProperty("file.separator");
if (fs.length() == 1)
char sep = fs.charAt(0);
if (sep != '/')
path = path.replace(sep, '/');
if (path.charAt(0) != '/')
path = '/' + path;
path = "file://" + path;
url = new URL(path);
catch (MalformedURLException e)
System.out.println("Cannot create url for: " + fileName);
System.exit(0);
return url; -
Help needed regarding insertion of data into oracle
Hi,
I am student currently trying to do a project to up a semantic database using oracle. Have set up the semantic technologies for oracle 11gr2 and used the jena adapter to load an owl into oracle.
But i am not sure how do i insert sample data that could reference the owl.
Tried searching but unable to find any simple tutorial and have also looked through the developer's guide and also jenaadaptor guide.
Is there any tutorials available that could help? thank youHi,
Please go to the OTN site for more information:
http://www.oracle.com/technology/tech/semantic_technologies/index.html
There you can find some training info (try the NCI Oracle By Example, it's a good tutorial):
http://www.oracle.com/technology/tech/semantic_technologies/htdocs/semtech_training.html
Regards,
Vladimir -
Best method to load XML data into Oracle
Hi,
I have to load XML data into Oracle tables. I tried using different options and have run into a dead end in each of those. I do not have knowledge of java and hence have restricted myself to PL/SQL solutions. I tried the following options.
1. Using DBMS_XMLSave package : Expects the ROWSET and ROW tags. Connot change format of the incoming XML file (Gives error oracle.xml.sql.OracleXMLSQLException: Start of root element expected).
2. Using the XMLPARSER and XMLDOM PL/SQL APIs : Works fine for small files. Run into memory problems for large files (Gives error java.lang.OutOfMemoryError). Have tried increasing the JAVA_POOL_SIZE but does not work. I am not sure whether I am changing the correct parameter.
I have read that the SAX API does not hog memory resources since it does not build the entire DOM tree structure. But the problem is that it does not have a PL/SQL implementation.
Can anyone PLEASE guide me in the right direction, as to the best way to achieve this through PL/SQL ??? I have not designed the tables so am flexible on using purely relational or object-relational design. Although would prefer to keep a purely relational design. (Had tried used object-relational for 1. and purely relational for 2. above)
The XML files are in the following format, (EXAMINEEs with single DEMOGRAPHIC and multiple TESTs)
<?xml version="1.0"?>
<Root_Element>
<Examinee>
<MACode>A</MACode>
<TestingJID>TN</TestingJID>
<ExamineeID>100001</ExamineeID>
<CreateDate>20020221</CreateDate>
<Demographic>
<InfoDate>20020221</InfoDate>
<FirstTime>1</FirstTime>
<LastName>JANE</LastName>
<FirstName>DOE</FirstName>
<MiddleInitial>C</MiddleInitial>
<LithoNumber>73</LithoNumber>
<StreetAddress>SomeAddress</StreetAddress>
<City>SomeCity</City>
<StateCode>TN</StateCode>
<ZipCode>37000</ZipCode>
<PassStatus>1</PassStatus>
</Demographic>
<Test>
<TestDate>20020221</TestDate>
<TestNbr>1</TestNbr>
<SrlNbr>13773784</SrlNbr>
</Test>
<Test>
<TestDate>20020221</TestDate>
<TestNbr>2</TestNbr>
<SrlNbr>13773784</SrlNbr>
</Test>
</Examinee>
</Root_Element>
Thanks for the help.Please refer to the XSU(XML SQL Utility) or TransX Utility(for Multi-language Document) if you want to load data in XML format into database.
Both of them require special XML formats, please first refer to the following docs:
http://otn.oracle.com/docs/tech/xml/xdk_java/doc_library/Production9i/doc/java/xsu/xsu_userguide.html
http://otn.oracle.com/docs/tech/xml/xdk_java/doc_library/Production9i/doc/java/transx/readme.html
You can use XSLT to transform your document to the required format.
If you document is large, you can use SAX method to insert data into database. But you need to write the code.
The following sample may be useful:
http://otn.oracle.com/tech/xml/xdk_sample/xdksample_040602i.html -
Inserting xml data in a MYSQL database
Hi,
I would like to know how i can insert data from an xml file into a MYSQL database using a java program, I currently have a program which retrieves an xml record and i need to insert the information between the tags into a table in MYSQL..please help me out if anyone knows...i am not very familiar with java...thanksHi there Sherkhan,
Im trying to do exactly what ur doing, inserting xml data in to a mySQL database. Any chance u could share the code for this???
Many thanks in advance. -
Putting XML data in Oracle 8i tables.
Hi,
For a ongoing project, I have to put XML data in Oracle
tables. I have to parse the XMl and extract few key items and
the rest of the XML is to put into CLOB column. I am looking to
use Event-based parser.
I was trying to use Oracle XML parser for PL/SQL. This parser
does not have SAX support curently. Does anbody know by when
this parser support SAX? It has already been promised as one of
the feature.
Can somebody suggest using some other parser? Can I use some
parser which can be integrated within Oracle so that I wont have
to use ODBC etc. for accessing tables.
Has somebody used Oracle XMl parser for Java ? Does parser
integrate within Oracle. How can we go about the procs of
parsing and putting results in oracle tables.
Looking forward to quick response,
Premal.
nullThere is no announced date for the addition of the SAX interface
to the PL/SQL Parser yet. Your current option is to use the XML
SQL Utility for Java to interchange XML data.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
Premal Mehta (guest) wrote:
: Hi,
: For a ongoing project, I have to put XML data in Oracle
: tables. I have to parse the XMl and extract few key items and
: the rest of the XML is to put into CLOB column. I am looking
to
: use Event-based parser.
: I was trying to use Oracle XML parser for PL/SQL. This
parser
: does not have SAX support curently. Does anbody know by when
: this parser support SAX? It has already been promised as one
of
: the feature.
: Can somebody suggest using some other parser? Can I use
some
: parser which can be integrated within Oracle so that I wont
have
: to use ODBC etc. for accessing tables.
: Has somebody used Oracle XMl parser for Java ? Does parser
: integrate within Oracle. How can we go about the procs of
: parsing and putting results in oracle tables.
: Looking forward to quick response,
: Premal.
null -
Load xml data into oracle table
Hi,
How to load the xml data in to oracle table plz guide in this context
thanksUse the DBMS_XMLSAVE.INSERTXML procedure.
It works fine. -
I want to transfer Data out of an XML-File into Tables using PL/SQL. All information I found, yet, is about traversing Data from XML using Java.
Any idea of Sources about using PL/SQL?There is no announced date for the addition of the SAX interface
to the PL/SQL Parser yet. Your current option is to use the XML
SQL Utility for Java to interchange XML data.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
Premal Mehta (guest) wrote:
: Hi,
: For a ongoing project, I have to put XML data in Oracle
: tables. I have to parse the XMl and extract few key items and
: the rest of the XML is to put into CLOB column. I am looking
to
: use Event-based parser.
: I was trying to use Oracle XML parser for PL/SQL. This
parser
: does not have SAX support curently. Does anbody know by when
: this parser support SAX? It has already been promised as one
of
: the feature.
: Can somebody suggest using some other parser? Can I use
some
: parser which can be integrated within Oracle so that I wont
have
: to use ODBC etc. for accessing tables.
: Has somebody used Oracle XMl parser for Java ? Does parser
: integrate within Oracle. How can we go about the procs of
: parsing and putting results in oracle tables.
: Looking forward to quick response,
: Premal.
null -
CMP to insert CLOB Data in Oracle
I have a CMP which tries to insert CLOB data into Oracle Database using XMLType column. We have tried multiple options
1. Inserting String data into XMLType column - if the value is more than 4000 chars, it gives an error
2. Inserting CLOB Data into XMLType column - Using the OracleCLob option in the deployment descriptor results in a SQLExcepotion Inconsistent datatype expected number found CLOB.
Can anybody provide a solution to this problem?I have a CMP which tries to insert CLOB data into Oracle Database using XMLType column. We have tried multiple options
1. Inserting String data into XMLType column - if the value is more than 4000 chars, it gives an error
2. Inserting CLOB Data into XMLType column - Using the OracleCLob option in the deployment descriptor results in a SQLExcepotion Inconsistent datatype expected number found CLOB.
Can anybody provide a solution to this problem? -
How to parse thus XML data?
Hi,experts:
In below thread:
Receiving .Net dataset with deployed proxies
i asked how to create a external definition in IR base on above XML data.
Now,i have created a XSD file base on the XML data.And importing it into IR successfully.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:Locale="zh-CN">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Status">
<xs:complexType>
<xs:attribute name="Result" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
And now,the question is how to parse the XML data in diffgr:diffgram segment.It seems a MS-XML syntax.Can it be parsed by XI?
I tried,but the following error occurs:
com.sap.aii.utilxi.misc.api.BaseRuntimeException: RuntimeException in Message-Mapping transformation: Cannot produce target element /ns0:ZMT_SD_ORDER01_RESULT. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd at com.sap.aii.mappingtool.tf3.AMappingProgram.startHi,
The above Exception seems to be because of mapping error.
Check your mapping for all the mandatory 1-1 mapping, also the 1-unbounded parent node mapping.
Once when you import the XSD and activate your External Definition if it does without any error then there is no problem with your External Definition.
If this error occurs only when you test your mapping then this is mapping error and not because of XSD.
Please check the parent node mapping like 1-unbounded.
Reward Points if useful
Regards
Ashmi.
Maybe you are looking for
-
IPod Touch (1st gen) simply doesn't work anymore. Help?
Horrible day it's been. I wake up and unplug my iPod Touch from its charger. The iPod Touch says it is fully charged. I go to school for a few hours, and come back. My iPod Touch's battery is completely drained. It was completely off, and it drained.
-
Accessing SAP:HopList element in message header from JAVA-mapping
Dear Experts, Is it possible to access the SAP:HopList element from message header in JAVA-mapping? I need this to get the list off all receivers of current message (I have a ReceiverDetermination with two receivers, without any conditions, so both
-
Billing date for a purchase order in the corresponding billing document
Hello, for a purchase order I need to select the billing date in the bill which corresponds to the purchase order. There is a posting date in the order history but I am not sure that this date is identical with the billing date in the purchase order.
-
VPN Issue: Could not Negotiate a connection with the remote PPP server
Hello Folks, I setup VPN on Windows Server 2003 Enterprise R2. I am successfully able to connect to VPN via laptop internally and externally. However, on my iPhone I am not able to connect and receiving the following error "Could not Negotiate a conn
-
In SD module is it possible to raise a credit note without reference to QUA
what is the tcode to create a crdit note in SD module? Is it VA01? In SD module is it possible to raise a credit note without reference to QUANTITY?