| From: | "Oliveiros C," <oliveiros(dot)cristina(at)marktest(dot)pt> |
|---|---|
| To: | "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, <hari(dot)fuchs(at)gmail(dot)com> |
| Cc: | <pgsql-sql(at)postgresql(dot)org>, <fhevia(at)ip-tel(dot)com(dot)ar> |
| Subject: | Re: Is there any function to test for numeric ips? |
| Date: | 2009-12-11 17:40:00 |
| Message-ID: | 78D47C9DA237489C8622D26C75548FAA@marktestcr.marktest.pt |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Howdy, Alvaro, Fernando and Harald.
Thanks a lot for your prompt reply.
As I'm in a big hurry with this I used the regular expressions thing, it
worked fine.
But your solution looks good as well, Alvaro, the problem is my poor
knowledge on pgplsql
Definitely, I have to study in more depth subjects like pgplsql not to
mention regular expressions
Thanx a lot for your fast help,
Best,
Oliveiros
----- Original Message -----
From: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>
To: "Oliveiros C," <oliveiros(dot)cristina(at)marktest(dot)pt>
Cc: <pgsql-sql(at)postgresql(dot)org>
Sent: Friday, December 11, 2009 4:28 PM
Subject: Re: [SQL] Is there any function to test for numeric ips?
> Oliveiros C, wrote:
>
>> 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?
>
> Yes, you can create a plpgsql function with an exception block; return
> false inside the exception, true otherwise. It looks something like
>
> begin
> perform $1::inet;
> return true;
> exception
> when invalid_something then
> return false
> end;
>
> I don't remember the exact syntax and the exception name but that should
> get you started.
>
> --
> Alvaro Herrera
> http://www.CommandPrompt.com/
> PostgreSQL Replication, Consulting, Custom Development, 24x7 support
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Britt Piehler | 2009-12-16 17:31:37 | 8.3/8.4 SQL incompatibility? |
| Previous Message | Alvaro Herrera | 2009-12-11 16:28:47 | Re: Is there any function to test for numeric ips? |