Re: How can I tell, in a trigger, if a value in a string is an integer.

From: Tomasz Myrta <jasiek(at)klaster(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How can I tell, in a trigger, if a value in a string is an integer.
Date: 2008-10-29 15:08:08
Message-ID: ge9u8q$15ll$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Philip W. Dalrymple napisal 29.10.2008 15:26:

> set_config('session.sessionid','23',false);

I validate strings with regexp. This expression returns true:

select '23' ~'^-{0,1}[0-9]+$';

If it's true - you can cast it safely:
select cast('23' as integer)

--
Regards,
Tomasz Myrta

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2008-10-29 15:22:36 Re: Replication with slony-I
Previous Message Sam Mason 2008-10-29 14:48:26 Re: Piping CSV data to psql when executing COPY .. FROM STDIN (Solved)