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

  • SEARCH
  • Home
  • 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 286111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:36:25+00:00 2026-05-12T05:36:25+00:00

We have an Oracle database that contains IP addresses stored as decimal integers –

  • 0

We have an Oracle database that contains IP addresses stored as decimal integers – this is incredibly painful when manipulating the data by hand instead of via the web interface, yet hand manipulation is really handy as the network guys continually ask us to do strange things that the web interface authors did not anticipate.

Could someone provide me with the PL/SQL or other method to display these decimal IPs as dotted decimal i.e. 123.123.123.123 format?

I.e. I’d like to be able to run a query such as :

select hostname, inttoip(ip_address) from host;

and have the inttoip() procedure display ip_address as 203.30.237.2 instead of as 3407801602.

Ideally I’d like a procedure which provides the inverse function too, e.g.

insert into host (hostname,ip_address) values ('some-hostname', iptoint('203.30.237.2'));

I have perl to do this, but my PL/SQL/Oracle knowledge is not good enough to port it into PL/SQL.

Alternatively a way to run the perl as the procedural language within the oracle context analogous to the following in postgres:

CREATE FUNCTION perl_func (integer) RETURNS integer AS $$
 <some perl>
$$ LANGUAGE plperl;

Would be great – if possible – probably even better as I could then do lots of procedural stuff within Oracle in a language I am familiar with.

  • 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-05-12T05:36:26+00:00Added an answer on May 12, 2026 at 5:36 am

    This is the function you need:

    create or replace
    function inttoip(ip_address integer) return varchar2
    deterministic
    is
    begin
        return to_char(mod(trunc(ip_address/256/256/256),256))
               ||'.'||to_char(mod(trunc(ip_address/256/256),256))
               ||'.'||to_char(mod(trunc(ip_address/256),256))
               ||'.'||to_char(mod(ip_address,256));
    end;
    

    (Comments about making function deterministic and using to_char taken on board – thanks).

    In Oracle 11G you could make the formatted IP address a virtual column on the host table:

    alter table host
    add formatted_ip_address varchar2(15)
    generated always as
    ( to_char(mod(trunc(ip_address/256/256/256),256))
              ||'.'||to_char(mod(trunc(ip_address/256/256),256))
              ||'.'||to_char(mod(trunc(ip_address/256),256))
              ||'.'||to_char(mod(ip_address,256))
    ) virtual;
    

    This column could then be indexed for queries if required.

    Your query becomes:

    select hostname, formatted_ip_address from host;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 Oracle database instances with the same data and scheme that I
I have a table in an Oracle database that contains actions performed by users
I have an Oracle 10g table that contains a # of log records. This
I have a GridView that pulls the data from an Oracle DataBase dynamically. <asp:GridView
I have a customer who has legacy data stored in Oracle database. Such data
I have a database table that contains collection data for product collected from a
Suppose the following scenario: I have a master database that contains lots of data,
I have an Oracle database that I am connecting to with PHP OCI8. One
We have an Oracle database here that's been around for about 10 years. It's
I have a SQL Server 2005 database that is linked to an Oracle database.

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.