Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Row updates from SQL based cursor
Message
From
08/08/2004 11:40:11
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00931295
Message ID:
00931631
Views:
32
Sergey

Here's the main code snippet that performs the SQL and update:

lnParam1 = 1000000001
=SQLExec(lnConnection, "execute ApplicationUserSelect1 ?lnParam1", 'myTable')
=SQL_Update_Table1('myTable', 'ApplicationUser', '*', 5)
replace myTable.Locked_By with 'Derek Chapman' in ltSQLRecordLock1
lnReturn=tableupdate(2, .T., 'myTable')

Here's the procedure that prepares the table for updates, the main 'code' simply builds the field list dynamically, rather than hardcoding it for each table:

Procedure SQL_Update_Table1
lparameters lcParam1, lcParam2, lcParam3, lnParam4
private all like l*

lcLocalTableFields = ''
lcRemoteTableFields = ''
for lnCount = 1 to fcount(lcParam1)
localTableFields = lcLocalTableFields + alltrim(field(lnCount)) + ', '
lcRemoteTableFields = lcRemoteTableFields + alltrim(field(lnCount)) + ' ' + lcParam2 + '.' + alltrim(field(lnCount)) + ', '
endfor

lcLocalTableFields = substr(lcLocalTableFields, 1, len(alltrim(lcLocalTableFields)) - 1)
lcRemoteTableFields = substr(lcRemoteTableFields, 1, len(alltrim(lcRemoteTableFields)) - 1)
lcLocalTableFields = iif(lcParam3 = '*', lcLocalTableFields, lcParam3)

sele &lcParam1
=CursorSetProp('KeyFieldList', lcLocalTableFields, lcParam1)
=CursorSetProp('WhereType', 3, lcParam1)
=CursorSetProp('Tables', lcParam2, lcParam1)

=CursorSetProp('UpdateNameList', lcRemoteTableFields, lcParam1)
=CursorSetProp('UpdatableFieldList', lcLocalTableFields, lcParam1)
=CursorSetProp('SendUpdates', .T., lcParam1)
=CursorSetProp('Buffering', lnParam4, lcParam1)
Return

Any ideas?

Regards

Derek
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform