Am Fre, 2003-09-26 um 16.17 schrieb Tim Bunce:
> On Fri, Sep 26, 2003 at 02:50:50PM +0200, Hendrik Fu� wrote:
> > Hi everyone,
> >
> > I've hacked together a few lines of perl and Inline C in order to bind
> > variables of type XMLType to placeholders. I can currently insert XML
> > data of less than 32k into an XMLType table or column, but I considered
> > integrating the code into DBD::Oracle, so that it would be available to
> > everyone.
>
> Great.
>
> > I'm still busy figuring out how to do that, but this raises some design
> > questions as well:
> >
> > In contrast to BLOB/CLOB etc. XMLType is a named type (SQLT_NTY), not a
> > primitive Oracle Type. So how should you specify the type name
> > ("SYS.XMLTYPE"), or should I rather invent a new SQLT_XMLTYPE?
>
> Why do you need to do either?
>
> Fetching an SQLT_NTY value should (I imagine) return some kind of
> 'handle' (a blessed reference) which can be passed to other methods
> to act on.
Very nice, should work with XMLType.
I'm going to concentrate on insert statements first, since you can
already fetch an XMLType using its getClobVal() member function.
The problem with inserting is, you can't do auto_lob-like operations
like
my $xml = "<test/>";
$sth->bind_param(1, $xml, {ora_type => ORA_NTY});
since bind_param does not know the name of the object type to bind
("SYS"."XMLType"). But one could use something similar to lob locators:
my $xml = $dbh->createXMLType( "<test/>" );
# constructs an OCIXMLType from string and returning a
# blessed reference ("OCIXMLTypePtr") to it
my $sth = $dbh->prepare( "INSERT INTO test_tab VALUES (?)" );
$sth->bind_param(1, $xml, {ora_type => ORA_NTY});
$sth->execute();
bind_param(), when given an ORA_NTY type then needs to retrieve the type
definition and call OCIBindObject().
Fetching an XMLType column might then return an OCIXMLTypePtr object for
each row, if auto_lob is disabled or the xml text as string if enabled.
However, OCIXMLType is undocumented (AFAIK) and I haven't tried
converting OCIXMLType to string yet.
Another issue is the size limitation of OCIStrings. If the XML document
grows larger, you would probably have to use temporary lobs to construct
the OCIXMLType.
Hendrik
--
hendrik fu�
morphochem AG
gmunder str. 37-37a
81379 muenchen
tel. ++49-89-78005-0
fax ++49-89-78005-555
[EMAIL PROTECTED]
http://www.morphochem.de