I have a problem to convert column with text values into integer values.
In table address i have column 'postcode' type TEXT. I have created a new column name 'postcode_int' type integer. In column 'postcode' some people wrote for example '330...' or '00234'. How can i check if the value is an integer.And if a value is an Integer then how to convert this values from type TEXT into type Integer and set them in column 'postcode_int' so that later i can do 'between '11111' and '99999'.
i tried to do something like this:
UPDATE adresse
SET postcode_int= case
when pg_typeof( REGEXP_REPLACE( COALESCE(trim( LEADING '0' FROM postcode), '0'),
'[^0-9]*' ,'0')::integer
) = integer
then postcode_int
else 0
end;
With regards
Andrey