Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Advice please - Sequences, how do you use them?
Everywhere you want to use a new sequence value, use seq_name.nextval
Everywhere you want the last use sequence value, use seq_name.currval
Examples:
/* load parent table */
insert into table1 (primary_key_column, column2,...) values (use seq_name.nextval, data1, data2....) /* load child table */ insert into table_2 (foregin_key_column, line_num, column3,...) values (use seq_name.currval, 1, text....) insert into table_2 (foregin_key_column, line_num, column3,...) values (use seq_name.currval, 2, line2_of_text....)
Carl Sarelius (Carl.Sarelius_at_bigpond.com) wrote:
: This is a multi-part message in MIME format.
: ------=_NextPart_000_001C_01BDBECD.D74469C0
: Content-Type: text/plain;
: charset="iso-8859-1"
: Content-Transfer-Encoding: quoted-printable
: Hi,
: I'm new to Pers Oracle 8 (and Oracle in general) and I'm after some =
: advice.
: For an assignment I have created a number of tables and put them in a =
: project. Each of these tables has a primary key identified. To ease data =
: input (at this stage through Navigator) I found a reference to the =
: "sequence" statement and created a sequence with the aim of =
: automatically creating the next number when inputting data.=20
: My question is - how do I use it? My manual is not so clear on the =
: method of execution. Also does the primary key attribute that the =
: sequence will update need to be of a specific data type?
Needs to be number if you are using a sequence generator.
: Advice appreciated.=20
: --=20
: Carl Sarelius
: Carl.Sarelius_at_bigpond.com
: Melbourne, Australia
: ------=_NextPart_000_001C_01BDBECD.D74469C0
: Content-Type: text/html;
: charset="iso-8859-1"
: Content-Transfer-Encoding: quoted-printable
: <!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
: <HTML>
: <HEAD>
: <META content=3Dtext/html;charset=3Diso-8859-1 =
: http-equiv=3DContent-Type>
: <META content=3D'"MSHTML 4.72.3110.7"' name=3DGENERATOR>
: </HEAD>
: <BODY bgColor=3D#ffffff>
: <DIV><FONT color=3D#000000 size=3D2>Hi,</FONT></DIV>
: <DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
: <DIV><FONT size=3D2>I'm new to Pers Oracle 8 (and Oracle in general) and =
: I'm after=20
: some advice.</FONT></DIV>
: <DIV><FONT size=3D2></FONT> </DIV>
: <DIV><FONT size=3D2>For an assignment I have created a number of tables =
: and put=20
: them in a project. Each of these tables has a primary key identified. To =
: ease=20
: data input (at this stage through Navigator) I found a reference to the=20
: "sequence" statement and created a sequence with the aim of=20
: automatically creating the next number when inputting =
: data. </FONT></DIV>
: <DIV><FONT size=3D2></FONT> </DIV>
: <DIV><FONT size=3D2>My question is - how do I use it? My manual is not =
: so clear on=20
: the method of execution. Also does the primary key attribute that the =
: sequence=20
: will update need to be of a specific data type?</FONT></DIV>
: <DIV><FONT size=3D2></FONT> </DIV>
: <DIV><FONT size=3D2>Advice appreciated. </FONT></DIV>
: <DIV><FONT color=3D#000000 size=3D2><BR>-- <BR>Carl Sarelius<BR><A=20
: href=3D"mailto:Carl.Sarelius_at_bigpond.com">Carl.Sarelius_at_bigpond.com</A><B=
: R>Melbourne,=20
: Australia</FONT></DIV></BODY></HTML>
: ------=_NextPart_000_001C_01BDBECD.D74469C0--
--
While DSC may claim ownership of all my ideas (on or off the job),
DSC does not claim any responsibility for them. Warranty expired when you
opened this article and I will not be responsible for its contents or use.
Received on Mon Aug 03 1998 - 07:17:51 CDT
![]() |
![]() |