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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i lock all the records who are the result of a query

Status
Not open for further replies.

Qwark

Programmer
Sep 26, 2000
59
0
0
NL
Hello,

I have a query:
cClubSQL = "SELECT clubnr, functienr FROM lid_club WHERE lidnr = " + ALLTRIM(STR(this.nLidnr)) + " INTO CURSOR curClubLid"
&cClubSQL

This query gives always 1 or more results.
from the table lid_club. Can i Lock these results automaticly. If the answer is yes HOW!!

Thanks for all tips,

Qwark
 
I have search agian, but haven't find the answer can you help me.

Qwark
 
If I understand the question, the answer is no. Assuming "clubnr" is the Primary key (and has an index named the same), you need to add the following code :

SET MULTILOCKS ON && jic
SCAN
IF SEEK(clubnr, "lid_clus", "clubnr")
LOCK("lid_clus")
ENDIF
ENDIF

Rick
 


This is kind of tricky. My solution will not get you 100% there but at least you can get thinking along these lines.

1.
Modify your table to have a primary key column (integer) and an update datetimestamp column and a user number column. Create a parameterized remote view on the table. Set the view to do updates based on primary key and update datetime.

2.
In your code, you have to do a multistep process. First try to lock everything via an SQL-Update where the user number column is equal to 000 (which could mean that "no one is using the rows"), setting it to your user number. Then do an SQL-Select on the view but include in the where clause "where user number equals my number."
Now you will only get rows you are supposed to have. Now edit them how you want but be sure to include logic to make the user number column set to 000. So when you do a tableupdate back to the source table the rows will be availble to others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top