Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 2ADE612DEACD for ; Mon, 23 Apr 2012 12:16:59 -0300 (ADT) Received: from mahout.postgresql.org ([98.129.198.123]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SML0Y-0008WD-KK for pgsql-bugs@postgresql.org; Mon, 23 Apr 2012 15:16:57 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SML0L-0001D6-7s for pgsql-bugs@postgresql.org; Mon, 23 Apr 2012 15:16:41 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1SML0K-0007Bo-TH for pgsql-bugs@postgresql.org; Mon, 23 Apr 2012 15:16:40 +0000 Date: Mon, 23 Apr 2012 15:16:40 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6609: pattern matching (version 8.2 or so...) To: pgsql-bugs@postgresql.org From: biju.george@ust-global.com X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201204/134 X-Sequence-Number: 32885 The following bug has been logged on the website: Bug reference: 6609 Logged by: biju george Email address: biju.george@ust-global.com PostgreSQL version: Unsupported/Unknown Operating system: Linux Description: = I have a text column which have values like '01abcd','012345','abcde',etc... 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, =3D, ~. Nothing seems to work. Tried ::text, ::integer and all... It always throws error -- ERROR: CASE types integer and text cannot be matched The darn thing just don't work... :mad: