PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Example: Updating a connected database
SQLModify (Example)
Example: Updating a connected database
WINDEVWEBDEV - Server codeReports and QueriesWindowsAjaxUser code (UMC)Hyper File 5.5OLE DBODBC This example uses a procedure to update a connected database.
// Procedure for updating the connected database
PROCEDURE ModCustomer
Res is boolean
QueryU, Query is string
Res = SQLExec("SELECT CUSTNUM, ZIP, CITY FROM CUSTOMER", "QRYSELECT")
IF Res = False THEN
// Process the error
END
SQLAssociate("QRYSELECT", CustomerNum, ZipCode, City)
// Update all the customers
SQLFirst("QRYSELECT")
WHILE not SQL.Out
IF City = "MONTPELLIER" THEN
// Run a modification query on the database
  QueryU = "UPDATE CUSTOMER SET ZIPCODE='34000'" + ...
 "WHERE CUSTNUM=" + CustomerNum
  // Run the query
  SQLExec(QueryU, "QRYUPDATE")
  // Update the associated table
  SQLInfo("QRYSELECT")
  // Same modification on the result
  // in order to not re-run the select query
  Query = CustomerNum + TAB + "34000" + TAB + City
  SQLModify("QRYSELECT", SQL.Current, Query)
  END
SQLNext("QRYSELECT")
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment