Solved

SQL to increment number by 1

Posted on 2009-04-02
7
1,149 Views
Last Modified: 2012-05-06
I like a simple Oracle SQL like the following so each run I will get a increment number by 1.  Please help.  It can be a sequence or anything you can think of.  Thanks.

select myseq from dual;

001
002
003
...
998
999
0
Comment
Question by:ewang1205
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 40

Assisted Solution

by:mrjoltcola
mrjoltcola earned 350 total points
ID: 24051892
create sequence myseq start with 1 increment by 1;

select myseq.nextval from dual;
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 50 total points
ID: 24051896
in what context to you need this?
please clarify.
0
 

Author Comment

by:ewang1205
ID: 24051919
squence number will be 1, 2, 3 not 001, 002,003.  

in what context to you need this?  This is just a SQL.  

Thanks.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 40

Accepted Solution

by:
mrjoltcola earned 350 total points
ID: 24051941
select to_char(myseq.nextval, '000') from dual;
0
 
LVL 23

Assisted Solution

by:David
David earned 100 total points
ID: 24051971
Or for a table insertion, ... values( myseq.nextval), col b, ....)
0
 
LVL 40

Assisted Solution

by:mrjoltcola
mrjoltcola earned 350 total points
ID: 24051995
Not sure what context you mean by "sql" but your requirement limits your sequence to 000 - 999, thats expected, right?
0
 

Author Closing Comment

by:ewang1205
ID: 31565880
Thanks for the solution.  
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to take different types of Oracle backups using RMAN.

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question