#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    13
    Rep Power
    0

    Insert into table if not exist otherwise return error


    Hello,

    I am using oracle 10g to create a user register application.
    what i want is to insert the user information (like Email ,username, password, etc.) into a table. i am able to insert the data into the table but what i want is to check before inserting that same email,and username doesnt exist. if it does it should return some error like the email or username already exist.

    please help and suggest some solution.
    it will be highly appreciated.

    thanks and regard,
    Kunal
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,057
    Rep Power
    383
    Simplest and best solution is to put a unique index on the combined fields.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    13
    Rep Power
    0
    thanks for the reply man.

    it helped.
    i defined a unique key on my column and validated it.

    much appreciated.

IMN logo majestic logo threadwatch logo seochat tools logo