pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliveiros C, <oliveiros.cristina@marktest.pt>
To: pgsql-sql@postgresql.org
Subject: Is there any function to test for numeric ips?
Date: Fri, 11 Dec 2009 16:05:34 -0000
Message-ID: <E94D918326D044C69895D829038E31B2@marktestcr.marktest.pt> (raw)

Dear All,

I have a table with host names and some happen to be numeric IPs.

I would like to be able to filter out the later.

Is there any function pre-defined in the system that can test a particular text type value to see if it is a numeric ip?

Something that returns true if applied to '192.168.1.1' but false if applied to 'videos.sapo.pt' ?

I considered NOT LIKE '%.%.%.%' but I'm affraid it will filter out host names like 'www.google.com.br'

I've realized that, for ex, inet 'x.x.x.x' will fail if the input is not a numeric IP, 
is there any simple and direct way to somewhat trap that error and convert it to a false value that can be used
in a WHERE clause?

This is not to be included in a program, I'm just interested in a query that I can do directly to the back end on a client program like pgAdmin.

I know very little ( nothing, actually...) about function creation in pgplsql, so, before investing in learning, I would like to know if there is any built in function that does the trick, so I can skip the (potential) learning curve.
So far, I've googled up and down but found none

Thanx in advance for your kind and valuable help

Best,
Oliveiros

view thread (6+ messages)  latest in thread

Message-ID: <E94D918326D044C69895D829038E31B2@marktestcr.marktest.pt>
Permalink:  ../E94D918326D044C69895D829038E31B2@marktestcr.marktest.pt/
Also on:    postgresql.org/message-id/E94D918326D044C69895D829038E31B2@marktestcr.marktest.pt

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: oliveiros.cristina@marktest.pt
  Subject: Re: Is there any function to test for numeric ips?
  In-Reply-To: <E94D918326D044C69895D829038E31B2@marktestcr.marktest.pt>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox