home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 11 / CDACTUAL11.iso / cdactual / demobin / share / os2 / VPREVAL / DATAPROC._ / ADDCUST next >
Encoding:
Text File  |  1994-01-13  |  1.6 KB  |  50 lines

  1. /****************************/
  2. /* Add customer information */
  3. /****************************/
  4. Arg window
  5. ret=0
  6.  
  7. /* Connect to Database */
  8. call sqldbs 'START USING DATABASE dbsample IN SHARED MODE';
  9. if (SQLCA.SQLCODE <> 0) then do
  10.     response=VpMessageBox(window,TITLE,'START USING DATABASE Error :  SQLCODE = ' SQLCA.SQLCODE)
  11.     response=VpMessageBox(window,TITLE,'Refer to the comment in the "When opened" event for information on how to create the database used by this program.')
  12.     return SQLCA.SQLCODE
  13. end
  14.  
  15. /* Get next unique customer number */
  16. temp = get_max(window "userid.customer" "CUST_CUSTOMER_ID")
  17.  
  18. if temp > 0 then do
  19.    cust.customer_id = temp;
  20.  
  21.    /* Create The SQL Insert Statement  and insert the record */
  22.    prep_string = "INSERT INTO userid.customer VALUES (",
  23.         cust.customer_id ",",
  24.         "'" || cust.name || "'" || ",",
  25.         "'" || cust.company || "'" || ",",
  26.         "'" || cust.address || "'" || ",",
  27.         "'" || cust.city || "'" || ",",
  28.         "'" || cust.state || "'" || ",",
  29.         "'" || cust.zip || "'" || ",",
  30.         "'" || cust.country || "'" || ",",
  31.         "'" || cust.phone || "'" || ")";
  32.  
  33.    call sqlexec 'EXECUTE IMMEDIATE :prep_string';
  34.    if ( SQLCA.SQLCODE <> 0) then do
  35.       response=VpMessageBox(window,TITLE,'Error adding customer record.' SQLCA.SQLMSG )
  36.       ret = SQLCA.SQLCODE
  37.    end
  38. end
  39.    else
  40.    ret = 1
  41.  
  42. /* Stop Using The Database */
  43. call sqldbs 'STOP USING DATABASE';
  44. if (SQLCA.SQLCODE <> 0) then do
  45.     response=VpMessageBox(window,TITLE,'STOP USING DATABASE Error :  SQLCODE = ' SQLCA.SQLCODE)
  46.     ret = SQLCA.SQLCODE
  47. end
  48.  
  49. return ret
  50.