Subject: casting, execute, name spaces

From: [email-masked]
Date: Mon, 26 Jul 93 06:31:47 -0700

Trivial questions from a complete database and postgres novice:

<Q1> casting

   % monitor -q test
   * create EG (num = float8, denom = int4) \g
   CREATE
   * append EG (num = 100.0, denom = 4) \g
   APPEND 20832
   * retrieve (div = EG.num / EG.denom) \g
   NOTICE:Jul 26 13:53:12:there is no operator / for types float8 and int4
   NOTICE:Jul 26 13:53:12:You will either have to retype this query using an
   NOTICE:Jul 26 13:53:12:explicit cast, or you will have to define the operator
   WARN:Jul 26 13:53:12:/ for float8 and int4 using DEFINE OPERATOR
   * retrieve (div = EG.num / EG.denom.int4out.float8in) \g
   ---------------
   | div         |
   ---------------
   | 25          |
   ---------------
   *

There has to be a better way of doing an "explicit cast" than what I did above
but I couldn't find any references to casting in the docs that come with 4.1.
Please enlighten me.

<Q2> execute

INTRODUCTION(COMMANDS) mentions an "execute" keyword.
Does it exist? Should there be a man-page for it?

<Q3> name spaces

(Continuing monitor session from above...)

   * retrieve (EMP.all) \g
   WARN:Jul 26 14:27:14:heap_openr on EMP failed

   * create EMP (name = char16, job = char16) \g
   CREATE
   * append EMP (name = "Jon", job = "annoying people") \g
   APPEND 20990
   * retrieve (EMP.all) \g
   -----------------------------
   | name        | job         |
   -----------------------------
   | jon         | annoying people|
   -----------------------------
   * retrieve (EMP.all) from EMP in EG \g
   -----------------------------
   | num         | denom       |
   -----------------------------
   | 100         | 4           |
   -----------------------------
   *

Does this just indicate that one should always use "from" clauses ?

-jonathan

--
Jonathan H N Chin, 5 kyu | Dept. of Cybernetics, | "Respondeo, etsi mutabor"
                         | University of Reading |
 [email-masked]   | Box 225, Whiteknights |   < Rosenstock-Huessy >
[email-masked]  | Reading, RG6 2AY, UK. |

---

From: [email-masked] (Paul M. Aoki)
Date: Mon, 26 Jul 93 07:44:45 -0700

>    * retrieve (div = EG.num / EG.denom.int4out.float8in) \g

EG.denom::float8

> Does it exist? Should there be a man-page for it?

it's part of the grammar, so it's a keyword.  no, it doesn't work.
so no, there shouldn't be a man page for it. :-)

>    * append EMP (name = "Jon", job = "annoying people") \g

er.. i don't understand your point.

a query containing the range variable EMP without a from clause will 
range over the EMP class.  if you define a range variable named EMP 
using a from clause, that range variable will range over the other 
class (in this case, EG).  there's no "context" or "ambiguity" that
can trip you up here.
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  [email-masked]
                |  Berkeley, CA 94720           |  ...!uunet!ucbvax!aoki