stored procs (with php and db2 on Linux)

wxdqz

New Member
I've been trying to call a stored procedure on DB2 UDB v7.1 from PHP4. I have encountered the following problems:

the CODE:
---------
<?php



define("DSN","V2");

define("USER","db2inst1");

define("PASSWORD","password");

print("Hey, I'm output! <BR>");


$db_conn=odbc_connect(DSN,USER,PASSWORD) or die("Unable to establish DB connection");


print("After the connection... <BR>");


/*$result=odbc_exec($db_conn,"SELECT * FROM FLOW");
print("The value of result is:".$result."<BR>");*/

//preparing the string to call the stored procedure
$result=odbc_prepare($db_conn,"CALL TEST_PROC2()");

print("The value of result is:".$result."<BR>");
print("After the prepare... Before the execute... <BR>");

//if $debug_mode is 0 (or false)
//the app server skips over this conditional and keeps running
//
//if $debug_mode is 1 (or true)
//the app server stops parsing and displays the produced HTML up to this point
if($debug_mode)
{
flush();
}

//executing the prepared string
if(!odbc_execute($result))
{
print("The odbc statement failed to execute! <BR>");
}
else
{

odbc_result_all($result);
}


?>



the PASSED URL (1):
----------------
<!-- w --><a class="postlink" href="http://www.foo.com/test_stored_proc.html?debug_mode=0">www.foo.com/test_stored_proc.html?debug_mode=0</a><!-- w -->

the RESULT (1):
---------------
A dialog box pops up and
says "The document contained no data,
Try again later, or contact the server's administrator"

the PASSED URL (2):
----------------
<!-- w --><a class="postlink" href="http://www.foo.com/test_stored_proc.html?debug_mode=1">www.foo.com/test_stored_proc.html?debug_mode=1</a><!-- w -->

the RESULT (2):
---------------
Hey, I'm output!
After the connection...
The value of result is:Resource id #2
After the prepare... Before the execute...



I've tried odbc_exec, odbc_prepare and odbc_execute, with {TEST_STORED_PROC()} and without the {}, and with different cursor_type parameters used when establishing the connection to the database. I have also tried calling other stored procedures. I can call the stored procedures in Java using a JDBC type 3 or 4 driver very well. The JDBC:ODBC (type 1) driver seems to have some issues of it's own.

I believe the database hangs or PHP hangs when ever I try to actually execute the storeded proc. I think it may be a problem with a function call made by PHP to the driver. Thus, the parsing of PHP scripts comes to a halt and the web server ends up not getting any of the HTML it expects.

Has anyone else tried calling stored procs from php? How is everything configured?

Incidently, is anyone using DB2 for Linux. I just wanted to know. I've been thinking about putting together some information about DB2 for Linux and setting up a forum to share information about it.
 
Back
Top