PDA

View Full Version : VARCHAR2 columns returns empty string in Oracle


frankisans
02-15-2011, 08:22 AM
Hello,

I am using the last release of Quercus included in Resin 4.0.15.
I have a grails application on tomcat that runs legacy PHP code with no problems. The application connects to an Oracle databse using the OCI8 extension.

A select query on a table's colum with VARCHAR2 type gives no results. I have find a workaround that consists on cast the column to a CHAR. For instance this code not prints the name:

$q = "SELECT name FROM users WHERE active = 1";
$stid = oci_parse($con, $q);
oci_execute($stid)
if (oci_fetch($stid)) {
$name = oci_result($stid, 0);

echo "Name:".oci_result($stid, 0);
}

but if I cast to a CHAR it works ok:

$q = "SELECT CAST(name AS CHAR(100)) FROM users WHERE active = 1";
$stid = oci_parse($con, $q);
oci_execute($stid)
if (oci_fetch($stid)) {
$name = oci_result($stid, 0);

echo "Name:".oci_result($stid, 0);
}

domdorn
02-17-2011, 03:34 PM
there's an existing issue regarding this problem
http://bugs.caucho.com/view.php?id=4224

until this is fixed, please use your workaround.

frankisans
05-25-2011, 02:02 PM
It fails because getBytes fails on the column. If use getString works well. Also with getUnicodeColumnString but is not possible to set unicode.semantics to true.
I have override getColumnString on OracleResult to use rs.getString.