Return-Path: pg_adm@postgres.berkeley.edu
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA08181; Tue, 13 Jul 93 06:34:49 -0700
Date: Tue, 13 Jul 93 06:34:49 -0700
Message-Id: <9307131334.AA08181@postgres.Berkeley.EDU>
From: Lydia Wuerfl <lwuerfl@cosy.sbg.ac.at>
Subject: problems
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu

Dear reader,
I have some problems concerning postfres. I am a student in Salzburg (Austria), computer science. 
Currently I am working on my MS thesis (schema evolution in databases).

1) 
My first question is concerning a query where I want to make a division, where
the arguments have different data types:
I have the following relatiopns:

* retrieve (total = int4sum {land.flaech})\g
---------------
| total       |
---------------
| 118805826   |
---------------  ... this is int4

* retrieve into erdoberfl (total = 4.0*6370.0*6370.0*3.14)\g
* retrieve (erdoberfl.all)\g
---------------
| total       |
---------------
| 5.09645864000000000e+08| ... this is foat8
---------------

how can I combine these two different types?
I need a division:

* retrieve (x = landfl.total / erdoberfl.total)\g
 
Query sent to backend is "retrieve (x = landfl.total / erdoberfl.total)"
NOTICE:Jul  1 08:54:12:there is no operator / for types int4 and float8
NOTICE:Jul  1 08:54:12:You will either have to retype this query using an
NOTICE:Jul  1 08:54:12:explicit cast, or you will have to define the operator
WARN:Jul  1 08:54:12:/ for int4 and float8 using DEFINE OPERATOR
 
What could I do?


2) 
I want to use some of the new data types offered by POSTGRES 4.1.
I had problems with the type point, when I wanted to work with distances.
I defines the following relation:

* create city (name = text, loc = point)\g

I want to get the distance between two cities

* retrieve (c1.all, DISTANCE)
from c1 in city, c2 in city
where ...

something like that, but how?

or all cities where the distance is less than a given value (a say that the distance has to be <= x miles)

please, could youd me some queries.

3)
Do you have C-functions concerning arrays?
I only found the file arrayfuncs.c
If you have any, please could you send it to me
do you have a description of the functions array_in and array_out
is array_in used by the append-statement
I would need a function to shorten the following query

* retrieve ... from ...
where grade[1] = 1 or grade[2] = 1 or ... or grade[5] = 1\g

the definition was
* create test ( ..., grade int4[],...)

the function should automatically check all array elements, if a
given value is in this array (e.g. if somebody has a 3)
a boolean should say if the result is true or false

I have written a C-function solvoing this problem.
Is ist possible to overload functions?
Because I want to write the function for text-arrays too.
Then I want to define an operator. This operator should accept all types 
(at this time int4 and text)

do you have information to solve that problem?

I would be very pleased if you could help me.
Thanks in advance

Lydia


