Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Autonumber
Hi bubba,
In Oracle we use SEQUENCE to do this. Create a sequence (see the CREATE SEQUENCE command in the SQL reference manual) and then when you insert a new row in your table set it to the NEXTVAL of your sequence. If you want to use the same value more than once, for example if you are creating an invoice header table and an invoice line item table where you want the line items to include the invoice number assigned when you create the invoice header table, you use CURRVAL.
Regards
Jerry
bubba wrote:
>
> In MS Access there is an autonumber type which guarentees a unique primary
> key that is automatically generated.
>
> I have created a test table with two fields on an oracle database.
>
> testID ---primary key - unique
> TestData -- varchar2 (50) nulls allowed
>
> When I try and enter data into the Testdata field using ODBC via MS access
> linked tables, I get an error message that says that testID cannot be null.
>
> Why doesn't oracle create a unique number here?
>
> What am i doing wrong?
>
> brittonb_at_webt.com
--
Jerry Gitomer Since I know how to spell DBA I became one.
jgitomer_at_p3.net
Received on Thu Apr 09 1998 - 22:29:47 CDT