For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > February 2008 > Re: [PHP-DB] No resultset with ocibindbyname









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] No resultset with ocibindbyname
Christopher Jones

2008-02-25, 7:01 pm

Manuel Schölling wrote:
> Hi guys,
>
> sorry for spamming your mailing list.
>
> I have a strange problem with ocibindbyname():
> I use this simple code to start an SQL query:


> But this query doesn't give me any data record (no error; empty resultset).


I couldn't reproduce your problem. What does your table look like?
What version of PHP & OCI8? What version of Oracle?

I tried this script:

<?php

$conn = oci_connect('hr', 'hrpwd', '//localhost/XE');

$stmtarray = array(
"drop table projekte_generisch",
"create table projekte_generisch (pid varchar2(40))",
"insert into projekte_generisch (pid) values ('einepid')"
);

foreach ($stmtarray as $stmt) {
$s = oci_parse($conn, $stmt);
@oci_execute($s);
}

$sql = "Select * from projekte_generisch where pid=:data";
$cur = oci_parse($conn, $sql);
var_dump($conn, $cur, $sql);

$pid = "einepid";
var_dump(ocibindbyname($cur, ":data", $pid));
var_dump(oci_execute($cur));

print '<table border="1">';
while ($row = oci_fetch_array($cur, OCI_RETURN_NULLS)) {
print '<tr>';
foreach ($row as $item) {
print '<td>'.($item?htmlentities($item):' ').'</td>';
}
print '</tr>';
}
print '</table>'

?>

The output is:

$ ~/php/bin/php t1.php
resource(5) of type (oci8 connection)
resource(9) of type (oci8 statement)
string(48) "Select * from projekte_generisch where pid=:data"
bool(true)
bool(true)
<table border="1"><tr><td>einepid</td><td>einepid</td></tr></table>

(The value is repeated because the array contains numerically and
associatively indexed values.)

Chris

--
Christopher Jones, Oracle
Email: christopher.jones@oracle.com Tel: +1 650 506 8630
Blog: http://blogs.oracle.com/opal/ Free PHP Book: http://tinyurl.com/f8jad
Manuel Schölling

2008-02-25, 7:01 pm

Hi Christopher,

thanks for caring about my problem. ;)

> I couldn't reproduce your problem. What does your table look like?
> What version of PHP & OCI8? What version of Oracle?

I using PHP 5.2.5 on a Linux 2.6.9 machine. The version of OCI8 is 1.2.4
(Revision 1.269.2.16.2.38, Oracle Instant Client Version 10.2).

The output of "select * from v$version" is:
Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
PL/SQL Release 8.1.7.0.0 - Production
CORE 8.1.7.0.0 Production
TNS for IBM/AIX RISC System/6000: Version 8.1.7.0.0 - Developmen
NLSRTL Version 3.4.1.0.0 - Production

And here is the output of "desc projekte_generisch":
Name Null? Type
PID NOT NULL CHAR(8)
ANFANG NOT NULL VARCHAR2(8)
ENDE VARCHAR2(8)
LAENGE NOT NULL NUMBER

And of course the data record I am searching for.

select * FROM projekte_generisch where pid='u0test'
PID ANFANG ENDE LAENGE
u0test utest 8

Hope this helps diagnosting the error.

Cheers,
Manuel
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com