Stored procedures

General discussion on Zend Server for IBM System i

Stored procedures

Postby alanjgorman on Thu Dec 20, 2012 8:55 pm

I'm having trouble getting results back from a stored procedure. This is the procedure:

CREATE PROCEDURE MYLIB/GETACCOUNT
( IN ACCOUNT CHAR(9), CUSTOMER CHAR(9) )
RESULT SETS 1
DETERMINISTIC
READS SQL DATA
CALL ON NULL INPUT
EXTERNAL NAME MYLIB/WEB100
PARAMETER STYLE SQL


$sql = "call mylib.getaccount(?,?)" ;
$stmt = db2_prepare($conn, $sql) ;
if (!$stmt)
die("Could not prepare sql statment. ".db2_stmt_errormsg()."<br>");
db2_bind_param($stmt, 1, "acount", DB2_PARAM_IN) ;
db2_bind_param($stmt, 2, "customer", DB2_PARAM_OUT) ;
if (!$result = db2_execute($stmt))
die("Could not retrieve record. ".db2_stmt_errormsg()."<br>");
$row = db2_fetch_array($stmt) ;
var_dump($row);

I get no errors but the array is always blank. The procedure is supposed to return 7 fields : last name, first name, middle name, address, city, state, and zip.

I've tried 9 "?" in the call statement with DB2_PARAM_OUT statements and that did not work.

How do I get info back when it is a RESULT SET?
alanjgorman
 
Posts: 6
Joined: Thu Nov 15, 2012 2:28 pm

Re: Stored procedures

Postby alanjgorman on Fri Dec 21, 2012 6:06 pm

OK, now I've tried this from the php.net web site:

while (db2_fetch_row($stmt)) {
$lastname = db2_result($stmt, 0);
$firstname = db2_result($stmt, 1);
print "Result is $lastname $firstname<br>";
}

and still get blanks. I verified on the server that I do have a record with the key I'm looking for.
alanjgorman
 
Posts: 6
Joined: Thu Nov 15, 2012 2:28 pm

Re: Stored procedures

Postby alanjgorman on Mon Jan 14, 2013 11:12 pm

Company that wrote the procedure got it fixed so it's working now.
alanjgorman
 
Posts: 6
Joined: Thu Nov 15, 2012 2:28 pm


Return to Zend Server for IBM i

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests