|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Autoincrement in Oracle, (Bit of a problem, Help please!)
I have a customer table that I have created in Oracle. This is linked to a web page via cgi script. Which inserts customer details from a HTML form to an oracle database.
The details cannot be inserted without customer ID. This customer ID needs to be auto_incremental. How do I make the cgi or the database auto_increment a customer number. Cheers JackD Last edited by pabloj : April 8th, 2004 at 07:41 AM. |
|
#2
|
|||
|
|||
|
One way is to user oracle sequence,
Create Sequence seq_name increment by 1 start with 1 nomaxvalue nocycle nocache; then, Create or replace trigger trig_name before insert on customer for every row declare a number(7); begin select seq_name.nextval into a from dual; :new.CustID = a; end; / Alternatively, code the above trigger as select max(CustID) into a from Customer; :new.CustID = a + 1; Now, just forget inserting CustID for new records, Regards, SeaBird. |
|
#3
|
||||
|
||||
|
Please use descriptive subjects in your posts!
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Bit of a problem, Help please! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|