ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / SQL functions
  • Example: Updating a connected database
SQLModify (Example)
Example: Updating a connected database
Reports and QueriesWindowsHyper File 5.5OLE DBODBC This example uses a procedure to update a connected database.
// Procedure for updating the connected database
PROCÉDURE 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
  // Execute 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

Last update: 05/26/2022

Send a report | Local help