Still on my 'figure out how to call an SQL UDF from PHP' trail of tears..

Here's my function definition:

CREATE FUNCTION NEWSYS.MSP_VALIDATESTOREFN (
STORE CHAR(3) )
RETURNS INTEGER
LANGUAGE RPGLE
SPECIFIC NEWSYS.MSP_VALIDATESTOREFN
NOT DETERMINISTIC
NO SQL
CALLED ON NULL INPUT
EXTERNAL NAME 'NEWSYS/MSPSRVPGM(MSP_VALIDATESTOREFN)'
PARAMETER STYLE GENERAL ;

Works fine when called from embedded SQL in RPGLE.

When I try and use it like this:

$SQLStmt = "SELECT * from cusmstp where NEWSYS.MSP_ValidateStoreFN(cast (?
as char (3) ) ) = '666'";
$prepare = db2_prepare($db2connection, $SQLStmt);
//db2_bind_param($prepare, 2, "$Wk_Error", DB2_PARAM_OUT);
db2_bind_param($prepare, 2, "$Wk_Store", DB2_PARAM_IN);
db2_bind_param($prepare, 1, "$Wk_Error", DB2_PARAM_OUT);
$stmt = db2_execute($prepare) or die("Failed SQL
Stmt:".$SQLStmt.":".db2_stmt_error().":".db2_stmt_errormsg());

with many variations on the sb2_bind_param and such, I get this:

[06-Feb-2013 16:40:11 UTC] PHP Warning: db2_bind_param() [<a
href='function.db2-bind-param'>function.db2-bind-param</a>]: Describe Param
Failed in /www/zendsvr/htdocs/myphp/mPOS/Data/mPosData.php on line 29
[06-Feb-2013 16:40:11 UTC] PHP Warning: db2_execute() [<a
href='function.db2-execute'>function.db2-execute</a>]: Value Not Bound in
/www/zendsvr/htdocs/myphp/mPOS/Data/mPosData.php on line 31
[06-Feb-2013 16:40:11 UTC] PHP Warning: db2_execute() [<a
href='function.db2-execute'>function.db2-execute</a>]: Binding Error 3 in
/www/zendsvr/htdocs/myphp/mPOS/Data/mPosData.php on line 31

I'm basically trying to duplicate this functionality:

// Test Validate Store function.
WkStore = '201';
Exec SQL
Set :WkError = MSP_ValidateStoreFN(:WkStore);

in PHP. Any ideas? Thanks!

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.