Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding duplicate keys
Message
From
14/01/1999 13:03:27
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00176022
Message ID:
00176076
Views:
32
Hi Michelle.

>I guess I'm not clear on error trapping. Do I do something like this:
>
>ON ERROR llNotSaved = .T.
>TABLEUPDATE()
>IF llNotSaved
>*Error message
>ON ERROR

You don't need to set ON ERROR, because TABLEUPDATE() will return .F. and you can use AERROR() to get an array of error information.

For example:

if tableupdate()
* everything is OK
else
aerror(laError)
if laError[1] = 1884
* duplicate key value
endif
endif

Rather than doing the error handling directly here (after all, there are a number of reasons why TABLEUPDATE may fail), you might want to put the code in a different method. eg:

if tableupdate()
* everything is OK
else
This.HandleError()
endif

and have HandleError do the job (likely using a CASE statement for different errors).

Doug
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform