Proxy class for a VFP local table with a remote copy
AUTOR: V. ESPINA VERSION: 1.0
EXAMPLES:
oProxy = CREATE("sqlProxy","c:\data\company.dbc!customers")
oProxy.remoteConnStr = "..."
?oProxy.localTable -> "customers"
?oProxy.remoteTable -> "customers"
?oProxy.dbcPath -> "c:\data\company.dbc"
oProxy = CREATE("sqlProxy","customers","erp_customers","conn-str")
oProxy.remoteConnStr = "conn-str"
?oProxy.localTable -> "customers"
?oProxy.remoteTable -> "erp_customers"
?oProxy.dbcPath -> ""
nConn = SQLSTRINGCONNECT("...")
oProxy = CREATE("sqlProxy","customers",,nConn)
oProxy.remoteConnStr = ""
?oProxy.localTable -> "customers"
?oProxy.remoteTable -> "customers"
?oProxy.dbcPath -> ""
SELECT customers
IF NOT oProxy.insertOne()
MESSAGEBOX(oProxy.lastError)
ENDIF
SELECT customers
SCATTER NAME oRow BLANK
oRow.<column> = <value>
oRow.<column> = <value>
...
IF NOT oProxy.insertOne(oRow)
MESSAGEBOX(oProxy.lastError)
ENDIF
SELECT FROM customers WHERE status = 'ACTIVE' INTO CURSOR qactives
IF NOT oProxy.insertMany("qactives")
MESSAGEBOX(oProxy.lastError)
ENDIF
SELECT customers
oRows = CREATE("Collection")
SCAN FOR status = "ACTIVE"
SCATTER NAME oRow
oRows.Add(oRow)
ENDSCAN
IF NOT oProxy.insertMany(oRows)
MESSAGEBOX(oProxy.lastError)
ENDIF
SELECT customers
LOCATE FOR id = "001"
REPLACE status WITH "INACTIVE"
IF NOT oProxy.updateOne()
MESSAGEBOX(oProxy.lastError)
ENDIF
SELECT customers
LOCATE FOR id = "001"
SCATTER NAME oRow
oRow.status = "INACTIVE"
IF NOT oProxy.updateOne(oRow)
MESSAGEBOX(oProxy.lastError)
ENDIF
oSets = oProxy.Where("status,lastupd","INACTIVE",DATETIME())
oWhere = oProxy.Where("zone","001")
IF NOT oProxy.updateMany(oSets, oWhere)
MESSAGEBOX(oProxy.lastError)
ENDIF
SELECT customers
LOCATE FOR id = "001"
IF NOT oProxy.deleteOne()
MESSAGEBOX(oProxy.lastError)
ENDIF
IF NOT oProxy.updateOne("001")
MESSAGEBOX(oProxy.lastError)
ENDIF
oWhere = oProxy.Where("zone","001")
IF NOT oProxy.deleteMany(oWhere)
MESSAGEBOX(oProxy.lastError)
ENDIF
oRow = oProxy.findOne("001")
IF ISNULL(oRow)
MESSAGEBOX("Not found!")
ELSE
MESSAGEBOX("Name: " + oRow.fullName)
ENDIF
oWhere = oProxy.Where("zone,status")
oWhere.Zone = "001"
oWhere.Status = "ACTIVE"
IF oProxy.findMany(oWhere, "qresult")
SELECT qresult
BROWSE
ENDIF