Re: [SQL] Odd sort behaviour

2009-09-01 Thread Rob Sargent
OK, I'm waking up now. My locale is as Scott suspected, en-US.UTF-8, and of course my server too. I guess I never really left "C" intellectually :) and we have a server that thinks SQL-ASCII is cool and comparing lists of names and emails between that server and my local utf-8 one was rather

Re: [SQL] Odd sort behaviour

2009-09-01 Thread Greg Stark
On Tue, Sep 1, 2009 at 11:31 PM, Rob Sargent wrote: > How many ways might one accidentally do that I wonder. Well most operating system distributions ask you when you install them what region you're in and use a collation for that region. In 8.4 you can check what collation a database is set to u

Re: [SQL] Odd sort behaviour

2009-09-01 Thread Rob Sargent
How many ways might one accidentally do that I wonder. Scott Marlowe wrote: On Tue, Sep 1, 2009 at 3:01 PM, Rob Sargent wrote: Since when does "." sort as "nothing at all" Since you set your locale equal to something like en_US instead of C -- Sent via pgsql-sql mailing list (pgs

Re: [SQL] Odd sort behaviour

2009-09-01 Thread Scott Marlowe
On Tue, Sep 1, 2009 at 3:01 PM, Rob Sargent wrote: > Since when does "." sort as "nothing at all" Since you set your locale equal to something like en_US instead of C -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mai

[SQL] Odd sort behaviour

2009-09-01 Thread Rob Sargent
Since when does "." sort as "nothing at all" This select select distinct u.user_name from subscriber_user u, subscription s, subscription_template t where u.id = s.subscriber_entity_id and s.template_id = t.id a

Re: [SQL] Plpgsql: Assign regular expression match to variable

2009-09-01 Thread Leif B. Kristensen
On Tuesday 1. September 2009, Ian Barwick wrote: >This seems to do what you want: > > my_int := (REGEXP_MATCHES(txt, E'^#(\\d+)'))[1]; Great! I had no idea that REGEXP_MATCHES() could do that kind of stuff. pgslekt=> select (REGEXP_MATCHES('#42 blabla', E'^#(\\d+)')) [1]::integer; regexp_match

Re: [SQL] Plpgsql: Assign regular expression match to variable

2009-09-01 Thread Ian Barwick
2009/9/1, Leif B. Kristensen : > In Plpgsql, I've got this problem of how to assign an integer extracted > from a regex to a variable. My approach so far feels kludgy: > > -- extract ^#(\d+) from txt > IF txt SIMILAR TO E'#\\d+%' THEN > my_int := SUBSTR(SUBSTRING(txt, E'#\\d+'), 2, > LE

[SQL] Plpgsql: Assign regular expression match to variable

2009-09-01 Thread Leif B. Kristensen
In Plpgsql, I've got this problem of how to assign an integer extracted from a regex to a variable. My approach so far feels kludgy: -- extract ^#(\d+) from txt IF txt SIMILAR TO E'#\\d+%' THEN my_int := SUBSTR(SUBSTRING(txt, E'#\\d+'), 2, LENGTH(SUBSTRING(txt, E'#\\d+')) -1)::INTEGER