Lists: | pgsql-general |
---|
From: | David Goodenough <david(dot)goodenough(at)btconnect(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Regular express question |
Date: | 2007-06-22 08:42:18 |
Message-ID: | 200706220942.19642.david.goodenough@btconnect.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
I have a table that consists of a set of regular expressions, a priority
and a result. I need to be able to match field in another table against
the set of regular expressions (ordered by priority) and use the first result.
Reading the documentation I can see how to put the regular expression
into an SQL statement (that is as text or a ? which my code provides) but
I can not see how to get the expression from the table.
David
From: | David Goodenough <david(dot)goodenough(at)btconnect(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Regular express question |
Date: | 2007-06-22 09:25:52 |
Message-ID: | 200706221025.53657.david.goodenough@btconnect.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On Friday 22 June 2007, David Goodenough wrote:
> I have a table that consists of a set of regular expressions, a priority
> and a result. I need to be able to match field in another table against
> the set of regular expressions (ordered by priority) and use the first
> result.
>
> Reading the documentation I can see how to put the regular expression
> into an SQL statement (that is as text or a ? which my code provides) but
> I can not see how to get the expression from the table.
>
> David
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
OK, I worked it out for myself. Of course I can put a field name on the
right hand side of the SIMILAR TO and the ? on the left had side, then it
works just as you would expect. So:-
select result from rules where ? similar to "rule" order by priority limit 1
gives me the answer I want.
David
From: | "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at> |
---|---|
To: | "David Goodenough *EXTERN*" <david(dot)goodenough(at)btconnect(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Regular express question |
Date: | 2007-06-22 14:00:05 |
Message-ID: | AFCCBB403D7E7A4581E48F20AF3E5DB20381A08A@EXADV1.host.magwien.gv.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
David Goodenough wrote:
>
> I have a table that consists of a set of regular expressions, a
priority
> and a result. I need to be able to match field in another table
against
> the set of regular expressions (ordered by priority) and use the first
result.
>
> Reading the documentation I can see how to put the regular expression
> into an SQL statement (that is as text or a ? which my code provides)
but
> I can not see how to get the expression from the table.
The only way I can see is to write a function in - say - PL/pgSQL.
Yours,
Laurenz Albe