Re: Oracle XMLTYPE column truncates

From: Date: Thu, 08 Mar 2007 15:37:54 +0000
Subject: Re: Oracle XMLTYPE column truncates
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-250075@lists.php.net to get a copy of this message
Hi Mikey, OCI doesn't directly support the XMLtype so you need to convert to string (if < 4k) or clob before retrieving. Use: select xml_metadata.getClobVal() ... OR select xml_metadata.getStringVal() ... If converting to clob, you get a clob object back and you'll need to run the load() method on it to get the text back. Roberto Mikey wrote: > Hi! > > I am running some tests for implementing variable metadata using > Oracle's XMLTYPE. Creating the XML and inserting it into the database > works fine, however when trying to retrieve data it truncates the > returned results. The code I am using to fetch the data is as follows: > > $row_sql = "SELECT xml_metadata FROM mdt1_metadata WHERE key_id = :kid"; > $row_sth = oci_parse ($conn, $row_sql); // $conn defined elsewhere > oci_bind_by_name ($row_sth, ":kid", $row['key_id']); > if (oci_execute ($row_sth)) { > $xml_row = oci_fetch_array ($row_sth, OCI_ASSOC); > try { > $xml = new SimpleXMLElement ($xml_row['xml_metadata']); > } > catch (Exception $e) { > echo "\n\n{$xml_row['xml_metadata']}\n\n"; > exit; > } > // stuff goes in here.... > } > > > I was wondering if anyone else on this list has had the same problem, or > knows of a better way of returning long values using OCI? > > TIA, > > Mikey

« previous php.general (#250075) next »