From: | joseph speigle <joe(dot)speigle(at)jklh(dot)us> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | substring syntax with regexp |
Date: | 2004-06-30 13:45:18 |
Message-ID: | 20040630084518.A21531@hovey.hoveymotorcars.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
hi,
Does anybody know offhand what is the correct way to use substr to extract the domain name from a client_referer column as logged by mod_pgsqllog (httpd module), by correcting the following:
the file 'hostname.sql' is pl/pgsql
main=> \e hostname.sql
ERROR: syntax error at or near "http" at character 290
LINE 13: newuri = substr(tempuri from 'http://[^/]*/.*');
^
I don't know, the docs are:
The substring function with two parameters, substring(string from pattern), provides extraction of a substring that matches a POSIX regular expression pattern.
(http://www.postgresql.org/docs/current/static/functions-matching.html)
the full 'hostname.sql' as is now is:
CREATE or replace FUNCTION hostname() RETURNS setof logpgsql.stats_type as
'
declare
row stats_type%ROWTYPE;
rec record;
newurl varchar(100);
tempurl varchar(100);
begin
for rec in SELECT * from stats
loop
row.c = rec.c;
tempurl = rec.url;
newuri = substr(tempuri from 'http://[^/]*/.*');
row.uri = newurl;
row.r = rec.r;
return next row;
end loop;
return next row;
return;
end
'
LANGUAGE 'plpgsql';
From | Date | Subject | |
---|---|---|---|
Next Message | joseph speigle | 2004-06-30 13:48:27 | Re: mysql2postgres has no documentation? |
Previous Message | Shridhar Daithankar | 2004-06-30 13:15:39 | Re: DML Restriction unless through a function |