Subject: Why doesnt this work

From: Jason Wilson <[email-masked]>
Date: Fri, 13 Dec 91 12:39:10 CST

We are running version 3.1 of postgres, and when we do the following:

create EMP (name = char[12],salary=float8,age=int4,dept=char[12])
define function no_pay(language = "postquel", returntype = EMP) arg is  (float8 ) as retrieve (EMP.all) where EMP.salary = $1

with appropiate "\g" on the ends the following is reported:

Query sent to backend is "define function no_pay(language = "postquel", returntype = EMP)  arg is  (float8 ) as     retrieve (EMP.all) where EMP.salary = $1 "
NOTICE:Dec 13 11:04:09:RelationBuildDesc: (relation name float8) nonexistent
 
WARN:Dec 13 11:04:09:heap_openr on float8 failed

Any help would be greatly appreciated.

-------------------------------------------------------------------------------
Jason 'Jay' Wilson                                      [email-masked]

---

From: postarch (Postgres Mailing Archive)
Date: Fri, 13 Dec 91 13:13:54 PST

you write:
> define function no_pay(language = "postquel", returntype = EMP) 
> arg is (float8 ) as retrieve (EMP.all) where EMP.salary = $1
> 

defining a postquel functions should be thought of as defining a method on 
an arbitrary class.  As is typical in the OO world an instance of the class
must be the first argument to the method.  Normally you would rewrite your
definition as follows:

	define function no_pay(language = "postquel", returntype = EMP)
	arg is (EMP, float8) as retrieve (EMP.all) where EMP.salary = $2

The problem with this is that the implementation of postquel functions is not 
yet up to snuff.  postquel functions currently can only accept the one base
type argument that associates the function with a particular class.  
Paramterized arguments will be coming out in release 4.0.

In the current implementation you would have to limit yourself to something
like the following:

	define function no_pay(language = "postquel", returntype = EMP)
	arg is (EMP) as retrieve (EMP.all) where EMP.salary = 1000.0

i.e. limit the salary to some predetermined constant.

Jeff Meredith
[email-masked]