Received: from stan.ringways.co.uk ([213.38.87.130]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f63GLka49305 for ; Tue, 3 Jul 2001 12:21:46 -0400 (EDT) (envelope-from gary.stainburn@ringways.co.uk) Received: from gary.ringways.co.uk ([10.1.1.2]) by stan.ringways.co.uk with smtp (Exim 3.13 #1) id 15HSpg-0008Mq-00; Tue, 03 Jul 2001 17:15:24 +0100 Content-Type: text/plain; charset="iso-8859-1" From: Gary Stainburn Organization: Ringways Garages Ltd To: "omid omoomi" , gary.stainburn@ringways.co.uk, pgsql-sql@postgresql.org Subject: Re: My First Function Date: Tue, 3 Jul 2001 17:08:06 +0100 X-Mailer: KMail [version 1.2] References: In-Reply-To: MIME-Version: 1.0 Message-Id: <01070317080604.03765@gary.ringways.co.uk> Content-Transfer-Encoding: 8bit X-Archive-Number: 200107/21 X-Sequence-Number: 3802 Okay, thanks for that. I'm getting far enough with my SQL to be able to read and understand that one, but how do I put that into a plsql function and how do I call it. Lets asume I've changed the relationship so that there is only one person per position, so only one integer should be returned. How do I get that integer returned to my perl/php script, and how do I return -1 if the result of the query is empty? Gary On Sunday 01 July 2001 5:39 pm, omid omoomi wrote: > >I want to be able to pass a member ID and a function ID and return the > >highest permission for the two. The cut-down schema is: > > Hello , > Perhaps this SQL works for you: > > select PPID,Max(PPERM) > from permtable > where > PFID = 'FUNCTION_ID' > and > PPID in ( select HPID from holdertable where HMID='MEMBER_ID' ) > group by PPID; > > You will face some problems returning more than one value from this SQL if > using it in a function. > Though,I believe if you are going to use a PHP script it can easilly be > handled with it. > > Hope that helps > Omid Omoomi > _________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000