Re: [GENERAL] new type question

2005-10-21 Thread Jim C. Nasby
Hrm, I thought there was something equivalent to an is_number() function, which would have made this easy: CASE WHEN is_number(x) THEN x ELSE NULL END; But I can't seem to find one. Is there a historic reason such functions don't exist? On Mon, Oct 17, 2005 at 01:05:17PM -0700, TJ O'Donnell wrot

Re: [GENERAL] new type question

2005-10-17 Thread TJ O'Donnell
I was needing something similar last week, not to throw an error, but to catch an error when 99% of my column's data is real, but some is not (e.g. '1.2-1.4' or '>32.7'). I wanted to do it in pure SQL, but settled on this. Is there a way to do this in pure SQL (so it will be faster)? Declare x

Re: [GENERAL] new type question

2005-10-17 Thread Jim C. Nasby
On Sun, Oct 16, 2005 at 11:03:52AM +0200, Sim Zacks wrote: > create function uint_in(val cstring) returns uint2 as > $$ > declare thisval int4; > begin > thisval=val::int4 > if thisval between 0 and 65535 then > return (thisval-32768)::int2; > else > return 0; > end if; > end > $$ language

Re: [GENERAL] new type question

2005-10-16 Thread Martijn van Oosterhout
On Sun, Oct 16, 2005 at 11:03:52AM +0200, Sim Zacks wrote: > I tried to create a new type with input and output functions in plpgsql and > it didn't work. > The error I got is there is no type uint2. > Is this because plpgsql does not allow you to create input/output fuctions? > It is a very simple

[GENERAL] new type question

2005-10-16 Thread Sim Zacks
I tried to create a new type with input and output functions in plpgsql and it didn't work. The error I got is there is no type uint2. Is this because plpgsql does not allow you to create input/output fuctions? It is a very simple function, so I didn't want to do it in C. Is there a reason that it