Skip site navigation (1) Skip section navigation (2)

Re: create function atof?

From: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: mark <postgresql(at)novacolor(dot)ca>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: create function atof?
Date: 2004-02-20 14:24:53
Message-ID: Pine.LNX.4.44.0402201617130.7099-100000@matrix.gatewaynet.com (view raw or flat)
Thread:
Lists: pgsql-sql
O kyrios mark egrapse stis Feb 20, 2004 :

> Hello,
> 
> Is it possible to create a database function that mimics the C function atof?
> I'm guessing it should look something like this:
> 
>         create function atof(varchar) returns float
>         as '??????'
>         language ????
>         returns null on null input;

Simply use
# select '<some float>'::text::float4;
or

create function atof(varchar) returns float language sql as 'select 
$1::text::float' returns null on null input;

> 
> Thanks,
> 
> Mark
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
> 

-- 
-Achilleus


In response to

pgsql-sql by date

Next:From: Tom LaneDate: 2004-02-20 14:54:14
Subject: Re: create function atof?
Previous:From: markDate: 2004-02-20 14:04:11
Subject: create function atof?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group