Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number Generator

Status
Not open for further replies.

GeneCampbell

IS-IT--Management
Jun 12, 2002
6
US
I want to generate a number and populated a table field via sql based upon a starting number. For example my starting number is 102, and I want to assign a number to a number field for each record in my table by incrementing the starting number by 1 for each record.
 
GeneCampbell,


the first that comes to my mind for autogeneration is csum function but the problem is u need to have a table with many rows so that u can generate autonumber for the series that u want to do..... for that purpose i used sys_calendar.calendar which contains some 73,414 rows... the below will generate auto numbers from 102 to 499... try to find a logic whereby u find out how for may rows u want to do insert......


select
sub.autonum
from
(
select
csum(1,1) as autonum
from
sys_calendar.calendar
)as sub
where
sub.autonum > 101
and sub.autonum < 500


maybe some one have a better way of doing....


regards


sridharan
 
You can add your starting number minus one to your CSUM attribute:

select name , (CSUM(1,1) +101)
from vendors ;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top