NYCPHP Meetup

NYPHP.org

[nycphp-talk] oci8 bind error

Eric Gewirtz eric.gewirtz at solutiononecdi.com
Mon Jun 29 12:16:01 EDT 2009


I'm getting the following error using oci_bind_by_name(). 

Warning: oci_bind_by_name(): ORA-01036: illegal variable name/number in
/appl/wideacc/CustMast/in/OCIpreptest.php on line 23

 

As you can see by the commented out bind lines, I have tried many different
parms in the bind and I tried the insert with the field names and without

 

I was getting the error on a "real" table so to isolate the issue I created
a test table with one field in it (the field is a varchar(25) and called
TESTNAME)

We are running php 5.2.2 with oci8 1.2.3 (rev 1.269.2.16.2.32),  against
Oracle 10g rel 10.2.0.2.0 on SunOS ver 5.10

 

What makes this even stranger, if I do not "die" on the failure of the bind
the oci_execute() returns true but no row is inserted into the table.

I can get this to work with PEAR_DB and MDB2 but we are doing some
performance testing so we want to see how using oci direct without any DB
layers performs.

Below is the test code I'm running;


//Connect to the Database 
$dbUser  = 'c1'; 
$dbPSWD  = p1'; 
$db = 'db1';  
$con = oci_connect($dbUser, $dbPSWD, $db); 
if (!$con) die ('Connect to DB failed'); 
//$insSQL = 'INSERT INTO KB_TEST (TESTNAME) VALUES (:TESTNAME)'; 
$insSQL = "INSERT INTO KB_TEST  VALUES (:TESTNAME)"; 
$insSQL = strtoupper($insSQL); // upper case since ORACLE prefers upper and
we know we do not have a case issue
echo "SQL is $insSQL \n"; 
$stmt = oci_parse($con, $insSql); 
if (!$stmt) die ('Parse for insert failed'); 
//oci_bind_by_name ($stmt, ":TESTNAME", "ERIC", 25, SQLT_CHAR); 

//oci_bind_by_name ($stmt, ":TESTNAME", "ERIC");

//oci_bind_by_name ($stmt, ":TESTNAME", "ERIC",-1);

//oci_bind_by_name ($stmt, ':TESTNAME', 'ERIC');

//oci_bind_by_name ($stmt, ':TESTNAME', 'ERIC',-1);
$val = 'ERIC'; 
$bindVar = ':TESTNAME'; 
if (oci_bind_by_name ($stmt, $bindVar, $val)) { 
        echo "Bind Successful \n"; 
}  else { 
        oci_close($con); 
        die ("***** Bind Failed ***** "); 
   } 
if (oci_execute ($stmt)) { 
        echo "execute was good \n"; 
} else { 
        echo "excute FAILED \n"; 
  } 
oci_close($con);

 

SolutionOne

Eric Gewirtz

162 Turk Hill Road

Brewster NY, 10509

Phone: 845-729-7800

FAX:    845-279-5502

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090629/e8601a51/attachment.html>


More information about the talk mailing list