Results 1 to 2 of 2

Thread: Should I check if data exists already or what ?

  1. #1

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Should I check if data exists already or what ?

    I'm using MySQL and I want to enter some data into the database.
    How should I check if that primary key is already in use ?

    For example say I'm using the product part number as the primary key, and a user wants to enter a new product.
    Should I do a SELECT query and check if no results were returned, or what...?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    I don't use MySQL, so this stuff relates to other DBMS's (SQL Server/Informix etc)

    Do you want the user to be able to enter the primary key? if not, just insert a null - the database will work the number out for you.

    Otherwise you would probably be best to do the select - you can't be sure that any error message will make sense to the user

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width