Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Appending a table that is in use.

Status
Not open for further replies.

woodyinoz

IS-IT--Management
Jan 8, 2002
215
GB
Hi all,

I'm trying to append information to a table that is already in use by another user. Quite predictably I get an error message when trying to do this.....

Can anybody suggest a way that I can append a live table?

Thanks,

Woody
 
"append a live table". I believe what you mean is "to append records to a table in use by someone [else]". Assuming that ...

Assume that your tables have a single-field primary key called, for our purposes, "PK"

var
tcMyNewData tCursor
tcLiveTable tCursor
endVar
tcMyNewData.open(":Alias:MyNewData")
tcLiveTable.open(":Alias:LiveTable")
tcLiveTable.edit()
scan tcMyNewData :
tcLiveTable.setRange("PK", "PK")
if tcLiveTable.nRecords() < 1 then ;all-new record
tcLiveTable.insertRecord()
tcLiveTable.copyRecord(tcMyNewData)
tcLiveTable.postRecord()
else ;updating existing record
if tcLiveTable.recordStatus(&quot;Locked&quot;) = False then
tcLiveTable.copyRecord(tcMyNewData)
tcLiveTable.postRecord()
else ;someone is editing it !
;note that this record wasn't copied,
;and come back later to do it !
endif
endif
tcLiveTable.setRange()
endScan

should allow you to update another table safely, even if someone else is editing it. If you know that they'll only be viewing it, you can cut out the part about locking and just copy the new data over the old record.

hth

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top