Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

sql help with insert query

 
Ranch Hand
Posts: 173
2
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, ranch!

First off I am sorry for my english grammar. I will try to describe my problem as clearly that i am able to.

I have a table which consists of two columns the first column consists of a
varchar as data type called "NAME" and the second has a BOOLEAN as a data type the later column is called "DELETEABLE".

I have values stored in this table which are of a default nature and are meant to be undeleteable by the user.
All theese values which are defaults is stored with the value deleteable set to false in the boolean column which means that the user
can on only delete records with values set to true in the recently mentioned location. New entries have "DELETEABLE" values set to true.
Before new records are inserted the insert query must first check if the value that are to be inserted exists or not. Sorry if i don't
have any code to provide as an example on how far i have gotten in this matter.

I am a beginner at sql and have a very basic knowledge but i am learning more and more. I hope I have been clear and not
too complicated. All help and hints are very much appreciated in advance!    

Best regards,
Robert!

 
Saloon Keeper
Posts: 6511
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you need a UNIQUE constraint on NAME - that prevents any records with an exiting name being inserted (it will cause an exception). You might also consider making NAME the primary key.
 
Climb the rope! CLIMB THE ROPE! You too tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic