Home » SQL & PL/SQL » SQL & PL/SQL » create Sequences Base 16
create Sequences Base 16 [message #259594] Thu, 16 August 2007 01:27 Go to next message
Rafeek
Messages: 159
Registered: April 2007
Location: egypt
Senior Member
hi all
how can i create Sequences with base 16 number
(Sequences Hex number) ?
thax
Rafeek
Re: create Sequences Base 16 [message #259597 is a reply to message #259594] Thu, 16 August 2007 01:41 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> create sequence s;

Sequence created.

SQL> select to_char(s.nextval,'XX') s from dual connect by level <= 16;
S
---
  1
  2
  3
  4
  5
  6
  7
  8
  9
  A
  B
  C
  D
  E
  F
 10

16 rows selected.

Regards
Michel
Re: create Sequences Base 16 [message #259604 is a reply to message #259594] Thu, 16 August 2007 01:49 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
A number is a number. The representation is what you make of it. With a to_char() you can display any number as hexadecimal:
CREATE sequence mhe_seq START WITH 1 INCREMENT BY 1
/

SELECT to_char(mhe_seq.nextval, 'XXXX') base_16
FROM   dual
CONNECT BY LEVEL < 100
/


DROP sequence mhe_seq
/


Is that what you were looking for?

MHE
Re: create Sequences Base 16 [message #260343 is a reply to message #259604] Sat, 18 August 2007 14:18 Go to previous messageGo to next message
Rafeek
Messages: 159
Registered: April 2007
Location: egypt
Senior Member
thax
can i create Sequences Base 64 ?
Re: create Sequences Base 16 [message #260344 is a reply to message #259594] Sat, 18 August 2007 14:26 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
>can i create Sequences Base 64 ?
We give up. Can you?
Re: create Sequences Base 16 [message #260345 is a reply to message #260343] Sat, 18 August 2007 14:38 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Yes.

Regards
Michel
Re: create Sequences Base 16 [message #260346 is a reply to message #260345] Sat, 18 August 2007 15:29 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Michel Cadot wrote on Sat, 18 August 2007 21:38
Yes.

Regards
Michel


Me too! Very Happy

MHE

[Updated on: Sat, 18 August 2007 15:29]

Report message to a moderator

Re: create Sequences Base 16 [message #260357 is a reply to message #260346] Sun, 19 August 2007 01:24 Go to previous messageGo to next message
Rafeek
Messages: 159
Registered: April 2007
Location: egypt
Senior Member
how can i create Sequences base 64 ?
Re: create Sequences Base 16 [message #260358 is a reply to message #260357] Sun, 19 August 2007 01:30 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What did you try?

Regards
Michel
Re: create Sequences Base 16 [message #260951 is a reply to message #260358] Tue, 21 August 2007 05:45 Go to previous messageGo to next message
Rafeek
Messages: 159
Registered: April 2007
Location: egypt
Senior Member
if u have any information tell me?
Re: create Sequences Base 16 [message #260954 is a reply to message #260951] Tue, 21 August 2007 05:50 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Who's "u"?

Anyway, have a look at Tom Kyte's page. That should get you started.

MHE
Re: create Sequences Base 16 [message #260965 is a reply to message #260951] Tue, 21 August 2007 06:43 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Rafeek,

Tell us what are the 64 digits?

Regards
Michel
Re: create Sequences Base 16 [message #260996 is a reply to message #260965] Tue, 21 August 2007 08:30 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Michel Cadot wrote on Tue, 21 August 2007 13:43
Rafeek,

Tell us what are the 64 digits?

Regards
Michel


Here are the characters described that make up base64. (Google is your friend Wink)

I don't see any use for this, however, except for a homework assignment.
Re: create Sequences Base 16 [message #260998 is a reply to message #260996] Tue, 21 August 2007 08:34 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Frank,

I know what they are, I just wanted to see if OP started to make his homework or if it is just waiting for us to do it. Wink

Regards
Michel
Re: create Sequences Base 16 [message #261001 is a reply to message #259594] Tue, 21 August 2007 08:48 Go to previous messageGo to next message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
If you are in oracle 10g then


insert into my_table(col1) values(UTL_RAW.CAST_TO_VARCHAR2(UTL_ENCODE.BASE64_ENCODE(UTL_RAW.CAST_TO_RAW(to_char(my_sequence.nextval)))));
Re: create Sequences Base 16 [message #261004 is a reply to message #261001] Tue, 21 August 2007 08:59 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Seems interesting but:
SQL> create sequence s;

Sequence created.

SQL> select s.nextval, 
  2         UTL_RAW.CAST_TO_VARCHAR2(UTL_ENCODE.BASE64_ENCODE(UTL_RAW.CAST_TO_RAW(to_char(s.nextval)))) b64
  3  from dual;
   NEXTVAL B64
---------- ----------
         1 MQ==

1 row selected.

Regards
Michel
Re: create Sequences Base 16 [message #261040 is a reply to message #259594] Tue, 21 August 2007 10:01 Go to previous messageGo to next message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
Thats true, but base64 represents everything as a readable character string and every number will be a unique string.

1 select s.nextval,
2 UTL_RAW.CAST_TO_VARCHAR2(UTL_ENCODE.BASE64_ENCODE(UTL_RAW.CAST_TO_RAW(s.nextval))) b64
3* from dual
4 /

NEXTVAL
----------
B64
--------------------------------------------------------------------------------
1
MQ==


whb@xe>/

NEXTVAL
----------
B64
--------------------------------------------------------------------------------
2
Mg==


whb@xe>/

NEXTVAL
----------
B64
--------------------------------------------------------------------------------
3
Mw==


whb@xe>/

NEXTVAL
----------
B64
--------------------------------------------------------------------------------
4
NA==


It would make no sense to me to use it, but you could.
Re: create Sequences Base 16 [message #261045 is a reply to message #261040] Tue, 21 August 2007 10:34 Go to previous message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Yes but I don't think this is the answer of the exercise. Very Happy

Regards
Michel
Previous Topic: updating date fields is there a better way using regular expressions?
Next Topic: Using PL/SQL to generate List to match Records
Goto Forum:
  


Current Time: Thu Dec 08 12:39:44 CST 2016

Total time taken to generate the page: 0.06455 seconds