473,654 Members | 3,040 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help on the Oracle Sequence Number

Ken
I got an Access database that need to be converted to Oracle 9i.
Somehow the Trigger we created to simulate the "AUTO NUMBER" on Access
could not create the sequence number as soon as the value has been
inserted. The sequence number can only be created after we go to the
second line. Please see the trigger below.

Is there anyway we could create a trigger that could create the
sequence number as soon as we enter a value? It should be very
similar to the "Auto Number" on Access, or "Identity Seed" on SQL
Server.

----------------------------------------------------------
1. sequence SNP.SECTION_ID_ SQ:

CREATE SEQUENCE SNP.SECTION_ID_ SQ
START WITH 1
INCREMENT BY 1
NOMINVALUE
NOMAXVALUE
NOCYCLE
CACHE 20
NOORDER
/
GRANT SELECT ON SNP.SECTION_ID_ SQ TO "PUBLIC"
/

2. Trigger SNP.SNP001_T_I_ GET_NEXT_SECTIO N_ID:

CREATE OR REPLACE TRIGGER SNP.SNP001_T_I_ GET_NEXT_SECTIO N_ID
BEFORE INSERT
ON SNP.SNP001_SECT ION
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW WHEN (new.section_id IS NULL)
BEGIN
SELECT section_id_sq.n extval
INTO :new.section_id
FROM dual;
END;
Nov 13 '05 #1
2 2514
Ken wrote:
Is there anyway we could create a trigger that could create the
sequence number as soon as we enter a value? It should be very
similar to the "Auto Number" on Access, or "Identity Seed" on SQL
Server.


No. You'd get the same behavior in SQL Server too, you might appreciate
the fact that the server cannot generate a number until you ask it to,
unless you save the record after entering the first bit of data (not
practical if you have required columns) then the first time you contact
the server about that record is when you've finished with it. Do what
everyone else does and re-design your front end to cope. You shouldn't
be *that* interested in the number that's been generated anyway.

Some groups dropped, FFS Ken, c.d.o.marketpla ce? You after a job?

--
This sig left intentionally blank
Nov 13 '05 #2
On 2 Dec 2004, kl*****@gmail.c om wrote:
I got an Access database that need to be converted to Oracle
9i. Somehow the Trigger we created to simulate the "AUTO
NUMBER" on Access could not create the sequence number as soon
as the value has been inserted. The sequence number can only
be created after we go to the second line. Please see the
trigger below.

Is there anyway we could create a trigger that could create the
sequence number as soon as we enter a value? It should be very
similar to the "Auto Number" on Access, or "Identity Seed" on
SQL Server.

----------------------------------------------------------
1. sequence SNP.SECTION_ID_ SQ:

CREATE SEQUENCE SNP.SECTION_ID_ SQ
START WITH 1
INCREMENT BY 1
NOMINVALUE
NOMAXVALUE
NOCYCLE
CACHE 20
NOORDER
/
GRANT SELECT ON SNP.SECTION_ID_ SQ TO "PUBLIC"
/

2. Trigger SNP.SNP001_T_I_ GET_NEXT_SECTIO N_ID:

CREATE OR REPLACE TRIGGER SNP.SNP001_T_I_ GET_NEXT_SECTIO N_ID
BEFORE INSERT
ON SNP.SNP001_SECT ION
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW WHEN (new.section_id IS NULL)
BEGIN
SELECT section_id_sq.n extval
INTO :new.section_id
FROM dual;
END;


No, the best you can do is put section_id_sq.n extval within your
insert statement.

--
Galen Boyer
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
4232
by: Philip D Heady | last post by:
Ok I'm a newbie to using Oracle9i w/ PHP, been a MySQL guy... What is the proper sql statement to use insert tables, etc. as below.? I don't know much about how OciParse works. I can connect successfuly, just my sql syntax is pretty bad. $conn = OCILogon($username,$passwd,$db); if ($conn) { $sql = "
1
8814
by: Phil Hindmoor | last post by:
Hi, I am sure if anyone can help me, you guys can! I am an Informix Developer, moving to Oracle 8i and later databases. I am struggling to find the Oracle equivelant to many of the useful Informix features that I have come to rely upon. I have looked through the Oracle/Infomix groups and some helpful users have posted some solutions, but many of them seem to be very complex work-arounds for features that were readily available in
2
4988
by: Ryan Wagner | last post by:
I am doing many SQL insert statements to insert records into an oracle database. I need the order of the records, after inserting all records, to be the same as the order I inserted them in. Right now my program fails to keep the records in order if the number of records is large. I inserted 100,000 records and the first record after all inserts were done was record#540. I have been told that the /*+ APPEND */ hint and /*+ PARALLEL */ hint...
1
9284
by: Mike Landis | last post by:
Hello, Has anyone a small tool or somekind of document which could help me to convert Oracle SQL scripts to SQL Server? Scripts are not very Oracle specified. Thanks, Below is a Script that I would e.g convert to MS SQLServer:
1
454
by: Ken | last post by:
I got an Access database that need to be converted to Oracle 9i. Somehow the Trigger we created to simulate the "AUTO NUMBER" on Access could not create the sequence number as soon as the value has been inserted. The sequence number can only be created after we go to the second line. Please see the trigger below. Is there anyway we could create a trigger that could create the sequence number as soon as we enter a value? It should be...
4
3328
by: dhcomcast | last post by:
We're starting to use Oracle for the back-end instead of a separate Access .mdb file for the data and everything as gone surprisingly well so far. We are learning Oracle as we go; Yikes! But we have very patient DBA's at the main office to answer newbie questions. Using Access 2002 with linked ODBC tables to Oracle 9 (9i? not sure), ODBC driver is SQORA32.DLL, verson 9.02.00.00. My "Error 3167: Record is deleted" comes when I use...
14
6399
by: ruediger.michels | last post by:
hi, 1. is there a statement in ms sql, what creates a sequence? cant find anything in web :-( -oracle: CREATE SEQUENCE XYZ INCREMENT BY 1 START WITH 1 NOCYCLE CACHE 20; -ms sql: ??? 2. hwo do i create a link to another ms-sql database
2
1692
by: charlie19102 | last post by:
We make use of sequences throughout our application. However, one in particular is causing concern. The sequence is tied to a table and increments when an insert trigger fires on the table. The sequence then becomes the primary key ( number 15 ) on the inserted row. In creating the sequence, 1 was established as the increment value. The number of rows in the underlying table is approximately 40,000; the sequence is over 216,000,000. We...
0
3474
debasisdas
by: debasisdas | last post by:
PL/SQL: Sequences ================ In Oracle, the sequences object provides a sequential series of numbers to applications without the overhead of disk I/O or transaction locking. These values are often used for primary and unique keys. In the previous release of Oracle Database, You can refer the sequence values in SQL statements with following pseudocolumns: CURRVAL returns the current value of a sequence. NEXTVAL
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.