Skip site navigation (1) Skip section navigation (2)

BUG #6609: pattern matching (version 8.2 or so...)

From: biju(dot)george(at)ust-global(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6609: pattern matching (version 8.2 or so...)
Date: 2012-04-23 15:16:40
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
The following bug has been logged on the website:

Bug reference:      6609
Logged by:          biju george
Email address:      biju(dot)george(at)ust-global(dot)com
PostgreSQL version: Unsupported/Unknown
Operating system:   Linux

I have a text column which have values like
Now I am trying to take the first 2 characters of the column and pass into a
function which takes only integer values and returns an integer. So, I need
to check before I input into the function whether the substring is integer
or not. If integer then the return value else default value say 99.
select my_function(case when substr(my_column,1,2) like '[0-9][0-9]' then
substr(my_column,1,2) else 99 end) from my_table;
I tried like, =, ~. Nothing seems to work. Tried ::text, ::integer and

It always throws error --
ERROR:  CASE types integer and text cannot be matched

The darn thing just don't work... :mad:


pgsql-bugs by date

Next:From: Александр ШепляковDate: 2012-04-23 22:23:38
Subject: Re: BUG #6607: Strange select behavior
Previous:From: Kevin GrittnerDate: 2012-04-23 14:53:03
Subject: Re: BUG #6607: Strange select behavior

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group