>
> I didn't try myself, but wrapping the whole into a PL/pgSQL function and
> using exceptions might do the work;
>
>
It's not good advice. I tested it, and problem is in where clause. I
don't understand problem well, but one possibility is change from cast
to to_number function like:
postgres=# begin;
BEGIN
postgres=# declare c cursor for select * from fx where to_number(b,'99999') > 0;
DECLARE CURSOR
postgres=# fetch from c;
a | b
----+----
10 | 20
(1 row)
postgres=# fetch from c;
a | b
----+-----
10 | a20
(1 row)
But still this solution is +/- correct
Regards
Pavel