Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to answer negative VFP attitude? Help...
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00427554
Message ID:
00430314
Views:
18
On SQL server the keys are kept in a table. The stored procedure just increments the key, then returns it to the client. You'll want wrap this in a transaction of better isolation. On the client side, I just increment an Appication property that holds an integer.

*- Client Code
*- Returns a new key
FUNCTION GetKey
LOCAL lnKey
oCMIS.lowkey = oCMIS.lowkey + 1
lnKey = ALLTR(STR(oCMIS.hikey)) + ALLTR(STR(oCMIS.lowkey))
RETURN VAL(lnKey)

*- Stored Procedure call at application startup that gets highkey
*- Took out error handling for clarity
lnKey = 0
= SQLEXEC(oCMIS.ConHandle, 'BEGIN TRANSACTION')
= SQLEXEC(oCMIS.ConHandle, '{CALL spGetNextHiKey(?@lnKey)}')
= SQLEXEC(oCMIS.ConHandle, 'COMMIT')
oCMIS.HiKey = lnKey
oCMIS.LowKey = 0

*- SQL Server Stored procedure that returns high key
*- Counters is table that holds key
CREATE PROCEDURE spGetNextHiKey(
@retval int = null OUTPUT)
AS
update Counters set nxthighkey = nxthighkey + 1
set @retval = (select nxthighkey from Counters)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform