• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Urgent Help required!!

 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Im relatively new to database and that too on Oracle. I have a problem in designing a table. Let this table be TableA. It has some fields. Let the combinational key in this table be a, b, c.
The field 'c' is of Integer type. My problem is this: I dont want the developer to gerenate the key 'c'. The different combinations of a, b, c are : a1,b1,1
a1,b1,2
a1,b1,3
a2,b1,1
a2,b1,2
a1,b2,1
a1,b2,2
etc.....
From this series you can see that whenever the a,b combination is the same, the c value will be different and consecutive (eg: first 3 rows).
How ever i can have the same c value, when the a, b combination is different. That is if i insert another row with a = a1 and b = b1, then the c value should be 4.

I hope u got my question.
How can i achieve this??
Someone told me i can use triggers
Please help me out
Kindest Regards
Saj
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need to create a composite primary key. This is very common, and if you refer to any Oracle manuals on how to create a table, they will show you how to create a primary key on the 3 columns.
 
get schwifty. tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!