Received: from bologna.nettuno.it (bologna.nettuno.it [193.43.2.1]) by hub.org (8.9.3/8.9.3) with ESMTP id IAA11605 for ; Tue, 15 Jun 1999 08:44:27 -0400 (EDT) (envelope-from jose@sferacarta.com) Received: from proxy.sferacarta.com (mail@sfcabop1.nettuno.it [193.207.10.213]) by bologna.nettuno.it (8.8.6/8.8.8/NETTuno 3.2) with ESMTP id OAA15568; Tue, 15 Jun 1999 14:44:06 +0200 (MDT) Received: from rosso.sferacarta.com (sferacarta.com) [10.20.30.5] by proxy.sferacarta.com with esmtp (Exim 2.05 #1 (Debian)) id 10tuSY-0006jh-00; Tue, 15 Jun 1999 14:45:06 +0000 Message-ID: <37664A1B.D0BF946@sferacarta.com> Date: Tue, 15 Jun 1999 14:42:03 +0200 From: =?iso-8859-1?Q?Jos=E9?= Soares X-Mailer: Mozilla 4.5 [it] (Win95; I) X-Accept-Language: it MIME-Version: 1.0 To: vikrant@chemquick.com CC: pgsql-sql@postgresql.org Subject: Re: [SQL] Mail about typecast References: <3765C5B3.C05DC56D@chemquick.com> Content-Type: multipart/alternative; boundary="------------D5BAC054225D3D9398D99D87" --------------D5BAC054225D3D9398D99D87 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Vikrant Rathore ha scritto: > Dear friends, > > I want to run a query : > > vikrant=> select date_part('epoch','12 hours'::timespan)::float4; > It returns a error message > ERROR: function dtof(float8) does not exist > > But i want to use typecast since the result of this query will be used > to update a field of type float4. > > I have checked the pg_proc system table it has a function dtof with > float8 as argument i have checked the list of functions also and > 'dtof(float8)' is shown in that list also. > can anyone solve this problem. I can solve the problem by using a c > program but i want to know when the function dtof(float8) is there in > pg_proc table then why it is not doing a typecasting. > Thanks in advance for your kind suggestion. > > Thanks & regards, > Vikrant. Which version of PostgreSQL are you using? This works for me. (v6.5) hygea=> \df dtof result|function|arguments|description ------+--------+---------+------------------------ float4|dtof |float8 |convert float8 to float4 (1 row) hygea=> select date_part('epoch','12 hours'::timespan)::float4; float4 ------ 43200 (1 row) hygea=> select date_part('epoch','12 hours'::timespan); date_part --------- 43200 (1 row) ______________________________________________________________ PostgreSQL 6.5.0 on i586-pc-linux-gnu, compiled by gcc 2.7.2.3 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Jose' --------------D5BAC054225D3D9398D99D87 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit  

Vikrant Rathore ha scritto:

Dear friends,

    I want to run a query :

vikrant=> select date_part('epoch','12 hours'::timespan)::float4;
It returns a error message
ERROR:  function dtof(float8) does not exist

But i want to use typecast since the result of this query will be used
to update a field of type float4.

I have checked the pg_proc system table it has a function dtof with
float8 as argument i have checked the list of functions also and
'dtof(float8)' is shown in that list also.
can anyone solve this problem. I can solve the problem by using a c
program but i want to know when the function dtof(float8) is there in
pg_proc table then why it is not doing a typecasting.
Thanks in advance for your kind suggestion.

Thanks & regards,
Vikrant.

Which version of PostgreSQL are you using?
This works for me. (v6.5)

hygea=> \df dtof
result|function|arguments|description
------+--------+---------+------------------------
float4|dtof    |float8   |convert float8 to float4
(1 row)

hygea=> select date_part('epoch','12 hours'::timespan)::float4;
float4
------
 43200
(1 row)

hygea=> select date_part('epoch','12 hours'::timespan);
date_part
---------
    43200
(1 row)

______________________________________________________________
PostgreSQL 6.5.0 on i586-pc-linux-gnu, compiled by gcc 2.7.2.3
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jose'
  --------------D5BAC054225D3D9398D99D87--