Win a copy of Spring in Action (5th edition) this week in the Spring 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

sql help with insert query  RSS feed

 
Ranch Hand
Posts: 36
Java Netbeans IDE PHP
  • 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: 5038
134
  • 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.
 
get schwifty. tiny ad:
Download Free Java APIs to Work with Office Files and PDF
htttp://www.e-iceblue.com/free-apis.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!