Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

IP Address to IP Value

376519Apr 10 2007 — edited Apr 11 2007
Hello
I am trying to convert a MSSQL Function that would take a IP Address (192.168.200.146) and return its numerical value (-1832343360).

Any help would be great!

The MSSQL Function is:

CREATE FUNCTION OctetsToIPValue
(
@octet1 TINYINT,
@octet2 TINYINT,
@octet3 TINYINT,
@octet4 TINYINT
)
RETURNS INT
AS
BEGIN
DECLARE
@Result INT,
@BValue BINARY(4)

SET @BValue =
CAST( @octet4 AS BINARY(1)) +
CAST( @octet3 AS BINARY(1)) +
CAST( @octet2 AS BINARY(1)) +
CAST( @octet1 AS BINARY(1))

SET @Result = CAST(@BValue AS INT )
RETURN @Result
END
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 9 2007
Added on Apr 10 2007
11 comments
694 views