Received: from hotmail.com (f73.law14.hotmail.com [64.4.21.73]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f64CeGa77261 for ; Wed, 4 Jul 2001 08:40:16 -0400 (EDT) (envelope-from oomoomi@hotmail.com) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Wed, 4 Jul 2001 05:40:12 -0700 Received: from 213.29.16.6 by lw14fd.law14.hotmail.msn.com with HTTP; Wed, 04 Jul 2001 12:40:11 GMT X-Originating-IP: [213.29.16.6] From: "omid omoomi" To: gary.stainburn@ringways.co.uk, pgsql-sql@postgresql.org Subject: Re: My First Function Date: Wed, 04 Jul 2001 12:40:11 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 04 Jul 2001 12:40:12.0298 (UTC) FILETIME=[77AC16A0:01C10486] X-Archive-Number: 200107/37 X-Sequence-Number: 3818 Hi, Then you would need some more normalized tables. But anyway ... create function maxfunc(text,text) returns int4 as ' select Max(PPERM) from permtable,holdertables where PFID = $1 and PPID = HPID and HMID= $2 group by PPID; ' language 'sql' ; ...where $1,$2 are the arguments. This would give you the corresponding access level number. But If using PHP then you may have some thing like this: I havn't test it my self, but sure it would work. good luck Omid >From: Gary Stainburn >To: "omid omoomi" , gary.stainburn@ringways.co.uk, >pgsql-sql@postgresql.org >Subject: Re: [SQL] My First Function >Date: Tue, 3 Jul 2001 17:08:06 +0100 > >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 > >---------------------------(end of broadcast)--------------------------- >TIP 4: Don't 'kill -9' the postmaster _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.