Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


Check for Existing Records Before doing Insert

Check for Existing Records Before doing Insert

I am using a script of Ken Puls to insert data from my Excel sheet into a table in my pervasive database. It works great , but i have come to realize that i need to check and make sure
that there are no existing records in my databse table that matches the data that i am about to insert. Long story short i do not need duplicate records in my database. I'll do my best to provide enough info.


my Name Range tblHeadings in Excel will have a column named Router_Number. This is the only column i need to check against the field Router_Number in my databse table. There will be a Field in my database table named Router_Number. To sum it up the code works it's way down the Router_number column in my Excel Sheet and looks for duplicates or same numbers in the Router_Number field in my database table. I've tried doing a select query but just can't seem to get it to work. can someone help?       I attached a link to the existing code


RE: Check for Existing Records Before doing Insert

What do you want to do if you find these "duplicate" values?  There's no "INSERT or UPDATE" type command in PSQL.  You could run a select on some unique value within the record to make sure it doesn't already exist and either skip the record or issue an UPDATE statement instead of an INSERT.  Are you sure you'll get duplicate records if you run the process?  If there is a unique index on any of the fields, you'll get an error (Status 5, duplicate key value) when trying to insert a duplicate value.   

Certified Pervasive Developer
Certified Pervasive Technician

RE: Check for Existing Records Before doing Insert

If it will give me an error when it find a duplicate that will be OK.  I'll check into it.  thanks for the help.  

Side Note:  This pervasive databse works with Globalshop ERP
            Do you have any experience working with Globalshop by any chance ?  


RE: Check for Existing Records Before doing Insert

It should give an error if there is some field that requires a unique value.  
You can look at the properties of the table in the Pervasive COntrol Center (right click the table name and select Properties) to see the fields, the field types, and the indexes.  You can look at the indexes and see if any are unique.  If they are and you are inserting a value that already exists, it will fail with a status 5.  

I have heard of Globalshop ERP but have not worked with it specifically.  


Certified Pervasive Developer
Certified Pervasive Technician

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close