If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Sequence

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-28-03, 11:43
Rob1982 Rob1982 is offline
Registered User
 
Join Date: Dec 2003
Posts: 22
Sequence

Hi,

I am trying to add some peoples detail's to my Oracle database, through ASP. I have set up the form, and text boxes for each indivdual fields, everything inserts fine apart from their ID, as this is a sequence in sql. So a number can be inserted automatically, rather than allowing the user to insert there own ID.

Any ideas how to make my asp page generate the sequence for the new ID?

Thanks
Reply With Quote
  #2 (permalink)  
Old 12-28-03, 12:25
ronanvanriet ronanvanriet is offline
Registered User
 
Join Date: Dec 2003
Posts: 4
Re: Sequence

Hello,

Why do you not have Oracle generate the sequence for you?

Here is an example

-- Start of DDL Script for Sequence SYSTEM.E_PROJECTS_ROW_ID_SQ
-- Generated 28-Dec-2003 18:17:13 from SYSTEM@ORACLE

CREATE SEQUENCE e_projects_row_id_sq
INCREMENT BY 1
START WITH 1
MINVALUE 1
MAXVALUE 999999999999999999999999999
NOCYCLE
NOORDER
NOCACHE
/


-- End of DDL Script for Sequence SYSTEM.E_PROJECTS_ROW_ID_SQ

Then your INSERT SP need to use the sequence.

INSERT INTO E_PROJECTS (ROW_ID, other columns)
VALUES E_PROJECTS_ROW_ID_SQ.NEXTVAL, other columns)

I hope this is what you are looking for.

Have fun!
Ronan van Riet
Reply With Quote
  #3 (permalink)  
Old 12-29-03, 21:47
arin_am arin_am is offline
Registered User
 
Join Date: Jun 2003
Posts: 34
Re: Sequence

I caution though... you might skip Sequence Number if you use Oracle sequence if this is Multi-user environment...
Cheers!!!!!!!!!
Quote:
Originally posted by ronanvanriet
Hello,

Why do you not have Oracle generate the sequence for you?

Here is an example

-- Start of DDL Script for Sequence SYSTEM.E_PROJECTS_ROW_ID_SQ
-- Generated 28-Dec-2003 18:17:13 from SYSTEM@ORACLE

CREATE SEQUENCE e_projects_row_id_sq
INCREMENT BY 1
START WITH 1
MINVALUE 1
MAXVALUE 999999999999999999999999999
NOCYCLE
NOORDER
NOCACHE
/


-- End of DDL Script for Sequence SYSTEM.E_PROJECTS_ROW_ID_SQ

Then your INSERT SP need to use the sequence.

INSERT INTO E_PROJECTS (ROW_ID, other columns)
VALUES E_PROJECTS_ROW_ID_SQ.NEXTVAL, other columns)

I hope this is what you are looking for.

Have fun!
Ronan van Riet
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On