× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Actually Jack, it ended up being a little more challenging.  I looped in Alan Seiden and he gave it a go as well.  He did give me some syntax help but I was never able to get the MERGE statement to work so I ended up with this that gets me to the same place with a little more verbosity:

?php
$conn_resource= db2_connect("*LOCAL", "", "");
if(!$conn_resource) {
echo"Connection failed. SQL Err:";
echodb2_conn_error();
echo"<br>";
echodb2_conn_errormsg();
exit();
}
/* Grab the parameters */
$cusnum= $_REQUEST["cusnum"];
$lastname= $_REQUEST["lastname"];
$initials= $_REQUEST["initials"];
$street=$_REQUEST["street"];
$city= $_REQUEST["city"];
$stateid= $_REQUEST["state"];
$zipcode= $_REQUEST["zipcode"];
$crdlmt= $_REQUEST["creditlimit"];
$charge= $_REQUEST["chargecode"];
$balance=$_REQUEST["balancedue"];
$credit=$_REQUEST["creditdue"];
/* Construct the SQL statements */
$sqlselect= "Select * from QIWS.QCUSTCDT where cusnum = ?";
$sqlupdate= "Update QIWS.QCUSTCDT set LSTNAM =?, INIT = ?,STREET = ?,CITY = ?,STATE=?,ZIPCOD=?,CDTLMT = ? ,CHGCOD = ?,BALDUE = ?,CDTDUE = ? where CUSNUM = ? ";
$sqlinsert= "Insert INTO QIWS.QCUSTCDT Values( ?,?,?,?,?,?,?,?,?,?,?)";
/* Prepare and execute the DB2 SQL statement */
$stmt= db2_prepare($conn_resource, $sqlselect);
$result= db2_execute($stmt, array($cusnum)) or die("Failed SQL Stmt:".$stmt.":".db2_stmt_error().":".db2_stmt_errormsg());
/* evaluate the success of the select and branch accordingly */
if(db2_fetch_array($stmt)){
error_log(print_r("Executing an update",true));
$stmt= db2_prepare($conn_resource, $sqlupdate);
$result= db2_execute($stmt, array($lastname,$initials,$street,$city,$stateid,$zipcode,$crdlmt,$charge,$balance,$credit,$cusnum,))
        or die("Failed SQL Stmt:".$stmt.":".db2_stmt_error().":".db2_stmt_errormsg());
}
else{
error_log(print_r("Executing an insert",true));
$stmt= db2_prepare($conn_resource, $sqlinsert);
$result= db2_execute($stmt, array($cusnum,$lastname,$initials,$street,$city,$stateid,$zipcode,$crdlmt,$charge,$balance,$credit))
         or die("Failed SQL Stmt:".$stmt.":".db2_stmt_error().":".db2_stmt_errormsg());
}
?>

Pete Helgren
www.petesworkshop.com
GIAC Secure Software Programmer-Java
GIAC Cloud Penetration Tester
AWS Certified Cloud Practitioner
Microsoft Certified: Azure Fundamentals

On 9/16/2023 10:36 AM, Jack Woehr via OpenSource wrote:
Which is line 44? Remembering that if there are blank lines in the actual
script you have to count them, too.


On Sun, Sep 10, 2023 at 6:17 PM Pete Helgren<pete@xxxxxxxxxx> wrote:

PHP Warning: db2_execute(): Value Not Bound in
/www/myapp/htdocs/DB_merge.php on line 44

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.