K, thanks guys.
To ultraslacker I've tried fieldname::TEXT. It's just another way of writing CAST(fieldname as TEXT). You still can't convert numeric types to strings.
Yes, this does work:
select lower(1234::text);
but this doesn't:
select lower(iPostCode::text) from table;
ERROR: Cannot cast type 'numeric' to 'text'
where iPostCode is NUMERIC(4,0) and that's what I need to be able to do.
And to chriskl well, I've tried your tests on my PostgreSQL and there must be a descrepency in our PostgreSQL versions becasuse I do not obtain the same results as you for these tests:
webdb=> select lower('1003'::numeric);
ERROR: Function 'lower(numeric)' does not exist
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts
webdb=> select lower(1003::numeric);
ERROR: Function 'lower(numeric)' does not exist
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts
webdb=>
select cast ('234213'::numeric as text);
ERROR: Cannot cast type 'numeric' to 'text'
Interestingly enough select lower(2003::integer); actually works... which is strange. I might experiment with this further...
Anyway, as you can see this is the point of my frustration. On your version they must have fixed these problems up, because they obviously are problems and it's just really anoying to know I can't even do simple stuff like this without it cracking at me.
Anyway, this is the error message I'm getting from PostgreSQL for my query:
ERROR: Function 'lower(numeric)' does not exist
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts
So what can I do? The only answer I've seen on the web is to use to_char() but that won't accept a string as a parameter.
The query has to be able to handle both numeric types and strings.
hehe. Yeah, I know PostgreSQL is more advanced then MySQL etc, but at least when you want to do something simple, there's a simple solution to it in MySQL. My experience with PostgreSQL has not been the same.
anyway, thanks for your reply guys.
cya
-Adam 🙂