From derby-user-return-9316-apmail-db-derby-user-archive=db.apache.org@db.apache.org Sat May 31 12:31:13 2008 Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 56808 invoked from network); 31 May 2008 12:31:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 May 2008 12:31:13 -0000 Received: (qmail 68896 invoked by uid 500); 31 May 2008 12:31:14 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 68874 invoked by uid 500); 31 May 2008 12:31:14 -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 68863 invoked by uid 99); 31 May 2008 12:31:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 May 2008 05:31:14 -0700 X-ASF-Spam-Status: No, hits=-1.0 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [192.18.6.24] (HELO gmp-eb-inf-2.sun.com) (192.18.6.24) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 May 2008 12:30:18 +0000 Received: from fe-emea-10.sun.com (gmp-eb-lb-2-fe3.eu.sun.com [192.18.6.12]) by gmp-eb-inf-2.sun.com (8.13.7+Sun/8.12.9) with ESMTP id m4VCUbJF006647 for ; Sat, 31 May 2008 12:30:40 GMT Received: from conversion-daemon.fe-emea-10.sun.com by fe-emea-10.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0K1Q00601FRZ3R00@fe-emea-10.sun.com> (original mail from Knut.Hatlen@Sun.COM) for derby-user@db.apache.org; Sat, 31 May 2008 13:30:37 +0100 (BST) Received: from [192.168.1.197] ([193.71.105.147]) by fe-emea-10.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0K1Q00MTZG31S330@fe-emea-10.sun.com> for derby-user@db.apache.org; Sat, 31 May 2008 13:30:37 +0100 (BST) Date: Sat, 31 May 2008 14:29:30 +0200 From: Knut Anders Hatlen Subject: Re: How to return an array of String in a Java routine? In-reply-to: <18db29d30805302026h4e828e6dud5f9435915164041@mail.gmail.com> Sender: Knut.Hatlen@Sun.COM To: Derby Discussion Message-id: <484144AA.7020807@sun.com> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7BIT References: <18db29d30805302026h4e828e6dud5f9435915164041@mail.gmail.com> User-Agent: Thunderbird 2.0.0.12 (X11/20080310) X-Virus-Checked: Checked by ClamAV on apache.org sin(EaTing), wrote: > Hi, > > I want to return an array of Strings from a Java routine. How could I > create the procedure declaration and definition. Hi, Derby doesn't support returning arrays from functions or stored procedures, I'm afraid. > Or if possible could I create my own ResultSet in my Java routine, and > manually insert rows into that ResultSet? Yes, that's possible. You can find an example on the wiki (http://wiki.apache.org/db-derby/DerbySQLroutines) that shows how to create a Java routine which returns a ResultSet. In the routine, you can return your array of strings as a ResultSet by executing a VALUES statement. To return the array {"one","two","three"}, you would execute VALUES 'one', 'two', 'three'. If more flexibility is needed, you can take a look at the table functions that were added in Derby 10.4. They allow you to use your own implementation of the java.sql.ResultSet interface. More details can be found here: http://db.apache.org/derby/docs/10.4/devguide/cdevspecialtabfuncs.html http://db.apache.org/derby/docs/10.4/ref/rrefcreatefunctionstatement.html -- Knut Anders