Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 22352 invoked from network); 26 Dec 2005 03:08:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Dec 2005 03:08:02 -0000 Received: (qmail 34014 invoked by uid 500); 26 Dec 2005 03:08:01 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 33963 invoked by uid 500); 26 Dec 2005 03:08:01 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 33951 invoked by uid 99); 26 Dec 2005 03:08:00 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Dec 2005 19:08:00 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of kartha02@gmail.com designates 64.233.184.207 as permitted sender) Received: from [64.233.184.207] (HELO wproxy.gmail.com) (64.233.184.207) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Dec 2005 19:07:59 -0800 Received: by wproxy.gmail.com with SMTP id 58so878785wri for ; Sun, 25 Dec 2005 19:07:38 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=lKIgmiTFFtPNJqIGp1Cf4iw0fdMi1lRLsLkU/o+4my4RwtF6LBymZsvFhywyHVGJ5WLKDib755SnyBFMRqaFyjGoC1tcO7rn2WFiMI76VDiDqMqnXUQmHuaquysy5cJXgYDdDW4iiGoC69GDf6w19YcEw/boFy2k4fYjutzep9g= Received: by 10.64.196.3 with SMTP id t3mr1025949qbf; Sun, 25 Dec 2005 19:07:38 -0800 (PST) Received: by 10.65.197.13 with HTTP; Sun, 25 Dec 2005 19:07:38 -0800 (PST) Message-ID: <44a78d040512251907m4900f8baw2a1a7a77b42c8c71@mail.gmail.com> Date: Sun, 25 Dec 2005 19:07:38 -0800 From: Rajesh Kartha To: Derby Discussion Subject: Re: How to select a random record. In-Reply-To: <43AF0540.6020001@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_17022_2576753.1135566458213" References: <43AF0540.6020001@gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_17022_2576753.1135566458213 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Maybe there are other ways to perform this, but the first thing that came t= o my mind was to create a Java stored procedure. This can use simple Java code to create the logic needed and return a result set from the products table based on the categories and a generate= d random number. Syntax for creating procedures: http://db.apache.org/derby/docs/10.1/ref/rrefcreateprocedurestatement.html Example: http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0408anders= on/#cs_sp Hope the above helps. -Rajesh On 12/25/05, Legolas Woodland wrote: > > Hi > Thank you for reading my post. > I have a Product table and a category table. > some of products exists in more than one category. > I should select a random product from product table (a record) and it > should be from some certain categories. > Now the question is : > What is best solution to select a random product which is in one or more > categories ( categories are determined by users ). > > > Thank you > > ------=_Part_17022_2576753.1135566458213 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Maybe there are other ways to perform this, but the first thing that came t= o my mind was to create a
Java stored procedure.  This can use simple Java code to create the lo= gic needed and return
a result set from the products table based on the categories and a generate= d random number.

Syntax for creating procedures:
http://db.apache.org/derby/docs/10.1/ref/rrefcreateproceduresta= tement.html

Example:
http://www-128.ibm.com/developerworks/db2/library/tec= harticle/dm-0408anderson/#cs_sp

Hope the above helps.

-Rajesh



On 12/25/05, Legolas Woodland <le= golas.w@gmail.com> wrote:
Hi
Thank you for reading my post.
I have a Product table and a catego= ry table.
some of products exists in more than one category.
I should= select a random product from product table (a record)  and itshould be from some certain categories.
Now the question is :
What is best solution to select a random produ= ct which is in one or more
categories ( categories are  determ= ined by users ).


Thank you


------=_Part_17022_2576753.1135566458213--