Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Validate XML: DateTime -> ORA-01830 / 01858

MarwimJul 27 2012 — edited Jul 27 2012
Hello,

I try to parse an XML document that contains an element that is defined as DateTime
<CreDtTm>2012-06-02T09:30:47.000Z</CreDtTm>
The xsd is as follows
<xs:element name="CreDtTm" type="ISODateTime"/>
...
<xs:simpleType name="ISODateTime">
  <xs:restriction base="xs:dateTime"/>
</xs:simpleType>
To me the format looks correct, but I get
ORA-01830: date format picture ends before converting entire input string
I found http://stackoverflow.com/questions/6370035/why-dbms-xmlschema-fails-to-validate-a-valid-xsdatetime/6382096#6382096
and changed the schema:
<xs:simpleType name="ISODateTime" xdb:SQLType="TIMESTAMP WITH TIME ZONE">
Now I get
ORA-01858: a non-numeric character was found where a numeric was expected
So I tried
ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT='yyyy-mm-dd"T"hh24:mi:ss.ff3"Z"';
and tested
select systimestamp from dual;

SYSTIMESTAMP
----------------------------------------
2012-07-27T10:52:05.860Z
The exact format, but still ORA-01858.

The validation is done with
DECLARE
  xmldoc XMLTYPE;
DECLARE
  xmldoc XMLTYPE;
BEGIN
    xmldoc := XMLTYPE(q'[<?xml version="1.0" encoding="UTF-8"?>
      ...
      <CreDtTm>2012-06-02T09:30:47.000Z</CreDtTm>
      ...]');
    xmldoc := xmldoc.createSchemaBasedXML('http://...xsd');
    XMLTYPE.schemaValidate(xmldoc);
END;
Does anyone know where I'm wrong?
select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE    11.2.0.2.0      Production
TNS for HPUX: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
Regards
Marcus

Edited by: Marwim on 27.07.2012 11:45
Added db-version
This post has been answered by odie_63 on Jul 27 2012
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 24 2012
Added on Jul 27 2012
5 comments
3,223 views