Path: newssvr20.news.prodigy.com!newsmst01.news.prodigy.com!prodigy.com!prodigy.com!news.glorb.com!postnews1.google.com!not-for-mail
From: davidr21@hotmail.com (Dave)
Newsgroups: comp.databases.oracle.tools
Subject: Re: Seeking recursive solution to replace nested for-loops
Date: 2 Mar 2004 21:31:04 -0800
Organization: http://groups.google.com
Lines: 55
Message-ID: <8244b794.0403022131.54687aa8@posting.google.com>
References: <aaba7f35.0402190919.31edd67f@posting.google.com> <GOxZb.9939$23.8686@lakeread04> <aaba7f35.0403010548.61f136b6@posting.google.com> <8244b794.0403011953.54f798d6@posting.google.com> <aaba7f35.0403020607.1d4ea02e@posting.google.com>
NNTP-Posting-Host: 146.115.66.127
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1078291864 16211 127.0.0.1 (3 Mar 2004 05:31:04 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 3 Mar 2004 05:31:04 +0000 (UTC)
Xref: newssvr20.news.prodigy.com comp.databases.oracle.tools:84923

mromano@sensis.com (Michelle Romano) wrote in message news:<aaba7f35.0403020607.1d4ea02e@posting.google.com>...
> > How about this?
> > 
> > create or replace function factorial(p_number in number) return number
> > is
> > begin
> >  if p_number = 1
> >  then
> >     return 1;
> >  else
> >     return factorial(p_number-1) * p_number;
> >  end if;
> > end;
> > /
> > 
> > create or replace function bd(p_n in number, p_k in number) return number
> > is
> > begin
> >   return factorial(p_n) / ( factorial(p_k) * factorial(p_n-p_k) );
> > end;
> > /
> > 
> > SQL> select bd(16, 4) from dual;
> > 
> >   BD(16,4)
> > ----------
> >       1820
> > 
> > Dave
> 
> Dave,
> 
> Your solution is great for obtaining the result of a numerical
> combination, but unfortunately, it is not exactly what I'm looking
> for.  I apologize for not including more detail in my original
> message.
> 
> I am working with non-numeric parameters and need the function to
> return each combination.  For example, if my parameters are
> a, b, c, d, e
> and I am looking for combinations in threes, the result would be:
> 
> a,b,c  a,b,d  a,b,e  a,c,d  a,c,e  a,d,e  b,c,d  b,c,e  b,d,e  c,d,e
> 
> Once I obtain this result, I will be running a series of procedures
> against each combination.
> 
> Michelle


Ah...I see. Would you mind posting your current nested-loop solution
as a starting point?

Thanks,
Dave
