Error with XMLTYPE

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jdorlon
Posts: 202
Joined: Fri 05 Jan 2007 22:07

Error with XMLTYPE

Post by jdorlon » Tue 06 Jul 2010 14:51

Hello,

I am using Delphi 2009, ODAC 6.9.0.58, Oracle 11.2.0.1 client and server. In ODAC, OraCall.OCIUnicode := True and OraSession.Options.UseUnicode := true;

When I create this table:

CREATE TABLE test_table2 (xmltext XMLTYPE)
XMLTYPE COLUMN xmltext STORE AS BINARY XML;

INSERT INTO test_table2
VALUES (xmltype ('hello'));

COMMIT;

then try to select from it using a TSmartQuery, I get an access violation. It works OK from SQL Plus, and from an older build of our application that used Delphi 7 and ODAC 6.25, with no unicode.

Is this an ODAC bug?

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Wed 07 Jul 2010 14:10

Hello

The error is generated by OCI function OCIPStreamRead if Unicode OCI environment is set. It seems like the OCIPStreamRead function cannot return XML if Unicode OCI environment is turned on and XML is stored as binary XML.

If you want to use the XMLTYPE type in you tables then you should set the OraCall.OCIUnicode variable to False or declare table column without the "STORE AS BINARY XML" declaration.

jdorlon
Posts: 202
Joined: Fri 05 Jan 2007 22:07

Post by jdorlon » Wed 07 Jul 2010 14:23

Thank you for the reply. Unfortunately, the workarounds are not options for me. Our application does support unicode, and the tables are created by the users, so I have no control over them.

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Thu 08 Jul 2010 10:11

I offer you several ways to resolve this issue:
- Set the OraCall.OCIUnicode variable to False
- Declare table column without the "STORE AS BINARY XML" declaration
- Modify your Select statement: select cast(xmltext as varchar2(1024)) xmltext from btest26
- Store your XML as CLOB or NCLOB (for storing in the Unicode charset)

If no solutions seem appropriate for you and you don't want to modify your application then you can ask the Oracle company to fix the OCIPStreamRead function for case when OCI client environment was initialized by the OCIEnvCreate function with value OCI_UTF16. As soon as the Oracle company fixes the OCIPStreamRead function you can read your XML without errors.

jdorlon
Posts: 202
Joined: Fri 05 Jan 2007 22:07

Post by jdorlon » Thu 08 Jul 2010 14:10

Thabk you for the additional information. I will open a case with Oracle. I just wish Oracle's support forum were as simple as this one!

jdorlon
Posts: 202
Joined: Fri 05 Jan 2007 22:07

Post by jdorlon » Thu 08 Jul 2010 22:44

Hello,

I have opened a case with Oracle on this. They will not investigate the unless I can "submit a pure OCI testcase that demonstrates the problem".

This would probably take me a while to put together. You don't happen to have a sample program like this handy, do you? The program just needs to run "select * from test_table2" with unicode enabled.

they also had this to say:
OCIPStreamRead does not appear to be a publicly documented OCI API. So most likely another public OCI API is calling that one privately. Just another factor to be aware of which will most likely complicate creating a testcase as you will need to mimic the public OCI API calls to reproduce this error.
Thanks,

John

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Mon 12 Jul 2010 15:04

Hello

OK. We will send you a small sample application to reproduce this issue. But it will take some time.

jdorlon
Posts: 202
Joined: Fri 05 Jan 2007 22:07

Post by jdorlon » Tue 13 Jul 2010 20:30

Thank you, that would be very helpful and I appreciate it!

jdorlon
Posts: 202
Joined: Fri 05 Jan 2007 22:07

Re: Error with XMLTYPE

Post by jdorlon » Tue 17 Mar 2015 18:07

Hello,

It's been almost 5 years. Can you find some time to build that sample app for me? A lot of our customers would really appreciate it.

Thanks,

John

m.ghilardi
Posts: 41
Joined: Thu 13 Mar 2014 11:14

Re: Error with XMLTYPE

Post by m.ghilardi » Mon 10 Aug 2015 13:04

I also need this fix.
Unless I set UseUnicode = false, I can't pass an OraXML as Input parameter of a TOraSQL without raising an Access Violation

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Error with XMLTYPE

Post by AlexP » Mon 17 Aug 2015 05:45

We cannot reproduce the problem. Please provide the code you are using for data insertion.

m.ghilardi
Posts: 41
Joined: Thu 13 Mar 2014 11:14

Re: Error with XMLTYPE

Post by m.ghilardi » Tue 25 Aug 2015 10:19

Hello AlexP,

I sent you an email with a project that reproduces the problem.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Error with XMLTYPE

Post by AlexP » Wed 26 Aug 2015 10:16

In the example you've sent, AV does not occur (in both cases). When you run the application, the error «OCI-31011: XML parsing failed» emerges.

m.ghilardi
Posts: 41
Joined: Thu 13 Mar 2014 11:14

Re: Error with XMLTYPE

Post by m.ghilardi » Thu 27 Aug 2015 07:15

I re-tested the project, OCI-31011 is not raised. Please be sure to have installed all the queues and the types in the SQL that I included inside in ODACQueue2.zip

Here is the environment I use


Oracle Linux
Oracle Database 11g Release 11.2.0.3.0 - 64bit Production

Client: 12.1.0.1.0
(Windows 7)

ODAC: 9.4.13

IDE:
Embarcadero® RAD Studio XE4 Version 18.0.4905.60485

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Error with XMLTYPE

Post by AlexP » Thu 27 Aug 2015 08:46

Please try to reproduce this behavior on the latest version 9.5.18 and let us know the results.

Post Reply