Handling Duplicate records 
Author Message
 Handling Duplicate records

When I try to a a record that already exists, I get a 'Key Violation'
error.  Can some explain how to handle this error?  I don't want the
duplicates added, but I want to branch to a different routine at the
error.



Fri, 19 Feb 1999 03:00:00 GMT  
 Handling Duplicate records



Quote:
> When I try to a a record that already exists, I get a 'Key Violation'
> error.  Can some explain how to handle this error?  I don't want the
> duplicates added, but I want to branch to a different routine at the
> error.

One way is to add another Ttable component to your form for searching.
In the OnValidate event of your TField do a findkey in the shadow table
for the record key to be added.  If found display you own message and
handle it in the OnValidate code.

BTW, a key violation error will keep a record from being added.

God Bless,

--

09/02/96 21:20
---------
Using: OUI PRO 1.5.0.2 from http://www.dvorak.com



Sat, 20 Feb 1999 03:00:00 GMT  
 Handling Duplicate records

Quote:

> When I try to a a record that already exists, I get a 'Key Violation'
> error.  Can some explain how to handle this error?  I don't want the
> duplicates added, but I want to branch to a different routine at the
> error.

Look up the 'try .. exception' part in your manual. It shows you how to
handle errors, and gives you an opportunity to branch of to another piece
of code.

  . .
Bj o rn  Sjunnesson



Sat, 20 Feb 1999 03:00:00 GMT  
 Handling Duplicate records

Quote:

> When I try to a a record that already exists, I get a 'Key Violation'
> error.  Can some explain how to handle this error?  I don't want the
> duplicates added, but I want to branch to a different routine at the
> error.

Trap the exeception this creates.  Take a look at exception handling in
the OLH for more information.

try
        Table.Post;
except
        RunSomeOtherProcedure;
end;

This block will RunSomeOtherProcedure no matter what exception is raised
by the post, out of memory, key violation, computer has vanished,
whatever.

--
Mark.



Sat, 20 Feb 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to handle duplicated keys?

2. duplicate records in join

3. Duplicate Error on insert record

4. Using SQL to delete duplicate records

5. Duplicate records

6. Tracking duplicate records?

7. Duplicate records in Interbase

8. Duplicating Records

9. Duplicating records D4 & Paradox

10. How to Duplicate Records with TTable Component

11. duplicate records in TDBGrid

12. append records without duplicates keys

 

 
Powered by phpBB® Forum Software