This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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,

Saloon Keeper
Posts: 5227
  • 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.
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!