![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I want to insert into a table and have a primary key being a number. It is not important that this number is incremental so is allowed to have "holes". I don't want to assign the number in my Java code. In Postgres and SQL Server I can set a column to be "autonumber" and the database automatically assigns it. Looking in Google it appears that this can't be done directly in Oracle. I have also checked and cannot find anything in the 10.2 manuals. I understand that I must "select sequencename.nextval into 'variablename' from dual" in a database trigger, then update :new.primarykeycolumnname with 'variablename'. If this is the only way of doing it then this is ok. But there is so much written in the newsgroup about pl/sql being slow so I don't want to code the trigger in pl/sql if there is a more efficient way of doing it. |
#3
| ||||
| ||||
|
|
Hi, I want to insert into a table and have a primary key being a number. It is not important that this number is incremental so is allowed to have "holes". I don't want to assign the number in my Java code. |
|
In Postgres and SQL Server I can set a column to be "autonumber" and the database automatically assigns it. |
|
Looking in Google it appears that this can't be done directly in Oracle. I have also checked and cannot find anything in the 10.2 manuals. I understand that I must "select sequencename.nextval into 'variablename' from dual" in a database trigger, then update :new.primarykeycolumnname with 'variablename'. If this is the only way of doing it then this is ok. But there is so much written in the newsgroup about pl/sql being slow so I don't want to code the trigger in pl/sql if there is a more efficient way of doing it. |
|
Could someone please tell me if everything I have written above is correct. And what are my alternatives to improve speed if it is slow. I will be using Oracle 10.2 on RH. |
#4
| |||
| |||
|
|
But there is so much written in the newsgroup about pl/sql being slow so I don't want to code the trigger in pl/sql if there is a more efficient way of doing it. |
#5
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |