Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8118727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:35:04+00:00 2026-06-06T04:35:04+00:00

Simply put, I’d like to be able to convert any string to an integer,

  • 0

Simply put, I’d like to be able to convert any string to an integer, preferably being able to restrict the size of the integer and ensure that the result is always identical. In other words is there a hashing function, supported by Oracle, that returns a numeric value and can that value have a maximum?

To provide some context if needed, I have two tables that have the following, simplified, format:

  Table 1                  Table 2

  id | sequence_number     id | sequence_number
  --------------------     -------------
  1  | 1                    1 | 2QD44561
  1  | 2                    1 | 6HH00244
  2  | 1                    2 | 5DH08133
  3  | 1                    3 | 7RD03098
  4  | 2                    4 | 8BF02466

The column sequence_number is number(3) in Table 1 and varchar2(11) in Table 2; it is part of the primary key in both tables.

The data is externally provided and cannot be changed; in Table 1 it is, I believe, created by a simple sequence but in Table 2 has a meaning. The data is made up but representative.

Someone has promised that we would output a number(3) field. While this is fine for the column in the first table, it causes problems for the second.

I would like to be able to both convert sequence_number to an integer (easy), that is less than 1000 (harder) and if at all possible is constant (seemingly impossible). This means that I would like '2QD44561' to always return 586. It does not matter, much, if two strings return the same number.

Simply converting to an integer I can use utl_raw.cast_to_number():

select utl_raw.cast_to_number((utl_raw.cast_to_raw('2QD44561'))) from dual;

UTL_RAW.CAST_TO_NUMBER((UTL_RAW.CAST_TO_RAW('2QD44561')))
---------------------------------------------------------
                                               -2.033E+25

But as you can see this isn’t less than 1000

I’ve also been playing around with dbms_crypto and utl_encode to see if I could come up with something but I’ve not managed to get a small integer. Is there a way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:35:06+00:00Added an answer on June 6, 2026 at 4:35 am

    How about ora_hash?

    select ora_hash(sequence_number, 999) from table_2;
    

    … will produce a maximum of 3 digits. You could also seed it with the id I suppose, but not sure that adds much with so few values, and I’m not sure you’d want that anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

simply put, i think that the input 'size' field is now obsolete (like the
Simply put, I'd like someone to be able to click a link, and get
There are several libraries like ncurses that assist in making command-line GUIs. Simply put,
Simply put, I have a string with a prefix msg followed by some numbers
I recently came across some Java code that simply put some strings into a
I've been reading a bit about immutable structures such as string. Simply put, they
Simply put, when a user wants people to be able to go to their
Simply put I would like to print to the console when my device is
Simply put: Is there any way to create non-modal JFace dialog? I've tried calling
Simply put; what does my $99 get me, that I can't already get for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.