Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Handling primary/candidate indexes w/ table buffering.
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00011524
Message ID:
00011587
Views:
27
>does anyone have some snippets so i could see how to properly handle unique key errors when the violation occurs because of a DELETED row with the same index values? Or for that matter whether the previous row is deleted or not.
>
>i'm using table buffering w/ TABLEUPDATE(), etc.
>
>thanks, kim

What I do is run a little SQL method before I commit/save the record.
The below code is from memory and may not be 100%, it is still early in the morning!
***
*** Dup check for adding a record.
LPARAMETER lcKey, lcTable, lcChkKey, lnRecNo

Select &lcKey,Recno() from &lcTable ;
Where &lcChkKey ;
into Array laTempCnt

IF _Tally > 0
* Check if edit mode
IF Thisform.cMode = "E"
* Check RecNo
IF lnRecno = laTempCnt[1,2]
* OK - Allow Edit to pass through
* Of course this assumes the U have your
* Referential Integrity stuff in place.
llflag=.T.
ELSE
* Problem - MessageBox()
llflag=.F.
ENDIF
ELSE
* Must be add node
* Problem - MessageBox()
llflag=.F.
ENDIF
ELSE
* OK Add the record
llflag=.T.
ENDIF

RETURN(llFlag)

This may seem a little strange, but I had other reasons which required this approach. Htwh. Steve
Steve Medvid
Systems Analyst

Environmental Resource Management
Previous
Reply
Map
View

Click here to load this message in the networking platform