Home » SQL & PL/SQL » SQL & PL/SQL » SEQUENCE (Oracle 9.2.0.1.0)
SEQUENCE [message #352988] Fri, 10 October 2008 07:19 Go to next message
suneelreddy
Messages: 11
Registered: May 2008
Location: india
Junior Member
Hi All,

Can we create a sequence in oracle with any Suffix.

for example i need sequence with suffix N

like N1000
N1001
N1002


pls guide.

Tnks in Advance

Suneel Reddy.R
Re: SEQUENCE [message #352992 is a reply to message #352988] Fri, 10 October 2008 07:42 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Not by using the CREATE SEQUENCE command (as it creates INTEGERS, not characters). However, you might add "N" by your own (using a database trigger, for example).

But, if you'd prefix (PREfix, not suffix) every number with an "N", what would be the purpose of doing that?
Re: SEQUENCE [message #353000 is a reply to message #352992] Fri, 10 October 2008 08:28 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
It seems to me I already saw this question... and answer. Smile

Regards
Michel
Re: SEQUENCE [message #353045 is a reply to message #353000] Fri, 10 October 2008 14:02 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
./fa/450/0/ Impossible!
Re: SEQUENCE [message #353189 is a reply to message #353000] Sun, 12 October 2008 12:17 Go to previous messageGo to next message
suneelreddy
Messages: 11
Registered: May 2008
Location: india
Junior Member
Hi Michel,

If you could remeber can you say the answer.

Rgds
Suneel
Re: SEQUENCE [message #353196 is a reply to message #353189] Sun, 12 October 2008 13:03 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I remember this answer (or the like):
Quote:
if you'd prefix (PREfix, not suffix) every number with an "N", what would be the purpose of doing that?

and this is the key point.
If all keys are prefix by N why do you want to store N?

Regards
Michel
Re: SEQUENCE [message #353270 is a reply to message #353196] Mon, 13 October 2008 02:41 Go to previous messageGo to next message
suneelreddy
Messages: 11
Registered: May 2008
Location: india
Junior Member
Hi Michel,

If we could prefix With N

in application level there are many sequences ..so if we could prefix with alphabets it could be easy to identify as an ID

example N1521 we could say that this id is from so and so module...

its for easy identification.

Hope you got it.

Regards
Suneel Reddy.R
Re: SEQUENCE [message #353274 is a reply to message #353270] Mon, 13 October 2008 03:20 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
So you didn't post the actual problem.
Post it now.
For Oracle, a sequence is a number.

Regards
Michel
Re: SEQUENCE [message #353277 is a reply to message #353270] Mon, 13 October 2008 03:32 Go to previous message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
In that case, this might be one way to do that:
SQL> select 'N' || to_char(my_seq.nextval) next from dual;

NEXT
-----------------------------------------
N71

SQL> select 'S' || to_char(my_seq.nextval) next from dual;

NEXT
-----------------------------------------
S72

SQL>
Previous Topic: Switch Time
Next Topic: How to Identify Table Usage Information
Goto Forum:
  


Current Time: Sat Dec 03 05:48:01 CST 2016

Total time taken to generate the page: 0.09337 seconds