Reputation: 203
I am attempting to call a DB2 function from PHP using zend_db to connect to DB2, and calling a SQL statement like so:
SELECT colA, colB, colC, mylib.testfunc(colA, colB, colC)
FROM otherlib.tableABC
WHERE colA = ... etc
(Just for reference, this is to call an RPG program that returns a specific value, so it is only returning one value). This works in an ACS Run SQL Scripts window, but when I try on Zend, I'm getting the following error:
Fatal error: Uncaught exception 'Zend_Db_Statement_Db2_Exception' with message 'TESTFUNC in MYLIB type *N not found. SQLCODE=-204'
I have double-checked to make sure my function does actually exist and it's in mylib. Doing a google search came up with nothing really helpful. Why would it be telling me that it doesn't exist? Is there something specific I have to configure when connecting to DB2 through Zend_DB?
In case it's important, I made the function like this:
CREATE OR REPLACE FUNCTION mylib.testfunc(iA DECIMAL(2,0), iB CHAR(4), iC DECIMAL(2,0))
RETURNS CHAR(10)
MODIFIES SQL DATA
LANGUAGE SQL
BEGIN
DECLARE oReturn CHAR(10) DEFAULT ' ';
-- Here I call a procedure I created to call the RPG
-- and format data...
RETURN oReturn;
END
Thanks in advance.
Upvotes: 0
Views: 143
Reputation: 12267
Is the userid (account-name) for connecting to Db2 the same between PHP and 'ACS Run SQL Scripts' ?
If not, verify that the account used for PHP has execute access to the function and whatever stored-procedures or external programs/routines the function invokes.
Additionally, when your SQL function CALLs the stored-procedure consider using a qualified stored-procedure name.
Upvotes: 2