I am currently designing an application in PHP that must connect to a DB2 database on an AS400.
On that server a huge application is already running, and I would like to use its full power by calling some
stored procedures that the developers will prepare for me.
As I have no AS400 on my LAN, i installed DB2 Universal Database personal edition on a windows 2000 server, the client
libraries and tools on a linux box, and started to play with my new toys.
I cataloged the server on the client, and after a few tries was able to connect to the remote DB2 from PHP pages, and
execute queries on it.
Then I wrote a very simple stored procedure in java: it gets one number as input as gives back two parameters,
input*2 and input+19. From the linux box I can connect to the remota database and eceute it:
db2 => call INFORETI.JAVA_PROCEDURE_1(1,?,?)
Value of output parameters
Parameter Name : VAR1
Parameter Value : 2
Parameter Name : VAR2
Parameter Value : 20
Return Status = 0
Then, following the few examples in the Unified ODBC section of the PHP manual, tried to execute it from a PHP page.
This is the relevant code
putenv("DB2INSTANCE=db2inst1");
$dbh = odbc_connect($dbname,$dbuser,$dbpass);
if (! $dbh)
print "ERRORE in odbc_connect($dbname,$dbuser,$dbpass)\n<br>".odbc_errormsg();
$sql = "CALL INFORETI.JAVA_PROCEDURE_1(?,?,?)";
$result = odbc_prepare($dbh,$sql);
if (! $result)
print "ERRORE in odbc_prepare(\$dbh,$sql)\n<br>".odbc_errormsg();
$arrParam=Array(1,0,0);
if (! @odbc_execute($result,&$arrParam))
print "ERRORE in odbc_execute(\$result)\n<br>".odbc_errormsg();
else
print_r($arrParam);
No matter what I write in the first element of $arrParam, the second and third one are always left untouched by the odbc_execute call.
Can anyone out there please help me?