Return-Path: owner-postman
Received: from localhost (localhost [127.0.0.1]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id SAA26291 for postgres-dist; Wed, 10 Nov 1993 18:25:06 -0800
Resent-From: POSTGRES mailing list <postman@postgres.Berkeley.EDU>
Resent-Message-Id: <199311110225.SAA26291@nobozo.CS.Berkeley.EDU>
X-Authentication-Warning: nobozo.CS.Berkeley.EDU: Host localhost didn't use HELO protocol
Sender: owner-postman@postgres.Berkeley.EDU
X-Return-Path: owner-postman
Received: from david.wheaton.edu (rmbenn@david.wheaton.edu [192.138.89.15]) by nobozo.CS.Berkeley.EDU (8.6.4/8.6.3) with SMTP id SAA26282 for <postgres@nobozo.CS.Berkeley.EDU>; Wed, 10 Nov 1993 18:25:03 -0800
Received: by david.wheaton.edu id AA12997
  (5.65c+/IDA-1.4.4 for postgres@postgres.berkeley.edu); Wed, 10 Nov 1993 20:24:24 -0600
Message-Id: <199311110224.AA12997@david.wheaton.edu>
Subject: Alias Functions
To: postgres@postgres.Berkeley.EDU
Date: Wed, 10 Nov 1993 20:24:23 -0600 (CST)
From: "Richard M. Bennema" <rmbenn@david.wheaton.edu>
X-Mailer: ELM [version 2.4 PL21]
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Length: 2082      
Resent-To: postgres-dist@postgres.Berkeley.EDU
Resent-Date: Wed, 10 Nov 93 18:25:06 -0800
Resent-XMts: smtp

My database class is using Postgres for the first time as an example database.

We are working are way through the User Manual and have run into a snag.
Section 7.1 on page 10 describes defining functions to be used as "aliases" for
commonly-used queries.  We have had no problem defining the function, but we
haven't been able to make it very useful.

Here is the example from the manual and what we've tried:
>> Script started on Wed Nov 10 20:10:10 1993
>> csh> cat emp_file
>> create EMP (name = text, salary = int4, age = int4, dept = char16)
>> 
>> append EMP (name = "Joe", salary = 1400, age = 40, dept = "shoe")
>> append EMP (name = "Sam", salary = 1200, age = 29, dept = "toy")
>> append EMP (name = "Bill", salary = 1600, age = 36, dept = "candy")
>> 
>> define function high_pay (language = "postquel", returntype = setof EMP)
>>     as "retrieve (EMP.all) where EMP.salary > 1500"
>> 
>> csh> monitor rich
>> Welcome to the C POSTGRES terminal monitor
>> 
>> Go 
>> * retrieve (this_works = name(high_pay())) \g
>> 
>> Query sent to backend is "retrieve (this_works = name(high_pay())) "
>> ---------------
>> | this_works  |
>> ---------------
>> | Bill        |
>> ---------------
>> 
>> Go 
>> * retrieve (this_doesnt = all(high_pay())) \g
>> 
>> Query sent to backend is "retrieve (this_doesnt = all(high_pay())) "
>> WARN:Nov 10 20:12:09:parser: syntax error at or near "all"
>> 
>> 
>> Go 
>> * high_pay() \g
>> 
>> Query sent to backend is "high_pay() "
>> WARN:Nov 10 20:12:17:parser: syntax error at or near "high_pay"
>> 
>> 
>> Go 
>> * \q
>> I live to serve you.
>> csh> 
>> script done on Wed Nov 10 20:12:25 1993
Is there a way to call an alias function without having to type out a retrieve
statement every time?  If there is not, is there any way to get multiple columns
returned instead of only one?  Any help would be appreciated.

					Thanks,

					Richard M. Bennema
-- 
rmbenn@david.wheaton.edu
Richard M. Bennema		"The brain can be seen as a complex machine,
Computer Science/Math		 like a gooey computer."
Wheaton College 			-Robert C. Solomon
