Return-Path: pg_adm@postgres.berkeley.edu
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA29966; Thu, 14 May 92 13:38:20 -0700
Date: Thu, 14 May 92 13:38:20 -0700
Message-Id: <9205142038.AA29966@postgres.Berkeley.EDU>
From: Stan Yates <SBYATES%PUCC.BITNET@cmsa.Berkeley.EDU>
Subject: retyping attributes in postquel queries
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu

    I am new to Postgres and am working my way through the manual.  I'm
discovering that some of the examples don't work as written because of type
conflicts.  For example, EMP.age is defined as int4 and EMP.salary as
float8.  So the following sort of thing happens:

Welcome to the C POSTGRES terminal monitor

Go
* retrieve(emp.all)\g

Query sent to backend is "retrieve(emp.all)"
---------------------------------------------------------
| name        | salary      | age         | dept        |
---------------------------------------------------------
| Sam         | 1.20000000000000000e+03| 29          | toy         |
---------------------------------------------------------
| Bill        | 1.60000000000000000e+03| 36          | candy       |
---------------------------------------------------------
| Joe         | 1.20000000000000000e+03| 40          | shoe        |
---------------------------------------------------------

Go
* retrieve(result=emp.salary/emp.age)\g

Query sent to backend is "retrieve(result=emp.salary/emp.age)"
NOTICE:May 14 15:33:07:there is no operator / for types float8 and int4

NOTICE:May 14 15:33:07:You will either have to retype this query using an

NOTICE:May 14 15:33:07:explicit cast, or you will have to define the operator

WARN:May 14 15:33:07:/ for float8 and int4 using DEFINE OPERATOR


    Is there a way to retype an attribute on the fly within a
postquel query?  I tried the following with no result:



Go
* retrieve(result=emp.salary/(float8)emp.age)\g

Query sent to backend is "retrieve(result=emp.salary/(float8)emp.age)"
WARN:May 14 15:34:02:type id lookup of 356 failed


Go
* retrieve(result=emp.salary/emp.age::float8)\g

Query sent to backend is "retrieve(result=emp.salary/emp.age::float8)"
NOTICE:May 14 15:34:28:there is no operator / for types float8 and int4

NOTICE:May 14 15:34:28:You will either have to retype this query using an

NOTICE:May 14 15:34:28:explicit cast, or you will have to define the operator

WARN:May 14 15:34:28:/ for float8 and int4 using DEFINE OPERATOR


    Thanks in advance.

--Stan Yates
