X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id F23A59F9C9E for ; Sun, 14 May 2006 23:56:12 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 84196-09 for ; Sun, 14 May 2006 23:56:08 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web54215.mail.yahoo.com (web54215.mail.yahoo.com [206.190.39.48]) by postgresql.org (Postfix) with SMTP id 545B69F946D for ; Sun, 14 May 2006 23:56:08 -0300 (ADT) Received: (qmail 79893 invoked by uid 60001); 15 May 2006 02:56:06 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=fuL7ZXyzGkSPSRC9eNEPowJ3x1whhZpTG7W1rKssUEqdulwwzomRHJoZk6XbTXOvihwE+DiLKRiDqbQGXh7Put1QbgPlbi/YFwKbMmu+zMnUz/9d5egaeX7hTz+/HW7SbYJdRyVAI8rsNYGvodRjBso2WIc1K/CuulcjiXvJqOY= ; Message-ID: <20060515025606.79891.qmail@web54215.mail.yahoo.com> Received: from [64.81.86.61] by web54215.mail.yahoo.com via HTTP; Sun, 14 May 2006 19:56:06 PDT Date: Sun, 14 May 2006 19:56:06 -0700 (PDT) From: "J." Subject: arrays as parameters in callableStatements To: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1032495245-1147661766=:79658" Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/42 X-Sequence-Number: 15170 --0-1032495245-1147661766=:79658 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit I've got a PL/pgSQL stored function in my database and I'm trying to figure out how to call it from my admin script. Some of the parameters are ArrayList objects of strings and it returns an array that I want to read to determine what the function actually did. Here is the function header(?): CREATE OR REPLACE FUNCTION add_thing( varchar, -- name:varchar ($1) integer, -- itemNum:integer ($2) varchar, -- owner:varchar ($3) varchar, -- image_url:varchar ($4) varchar, -- specs_url:varchar ($5) varchar[], -- categories[]:varchar ($6) varchar[], -- component_name[]:varchar ($7) varchar[], -- component_id[]:varchar ($8) date[], -- component_date[]:date ($9) varchar[] -- componentImage_url[]:varchar ($10) ) RETURNS varchar[] as ' Here is how I'm trying to call it in Java: // Turn transactions off. connection.setAutoCommit(false); // Procedure call. CallableStatement stmt = connection.prepareCall("{ ? = call add_thing( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) }"); stmt.registerOutParameter(1, Types.ARRAY); stmt.setString(2, name); stmt.setInt(3, itemNum); stmt.setString(4, owner); stmt.setString(5, item_url); stmt.setString(6, specs); stmt.setObject(7, compNames); stmt.setObject(8, compIds); stmt.setObject(9, compDates); stmt.setObject(10, compURL); stmt.execute(); String[] results = stmt.getArray(1); stmt.close(); I'm getting a compiler error "Incompatible Types" on the second to last line. Looking at the API to me it seems like that's how it should work. I'm thinking of trying getResultSet() instead, but since this is only the compile stage I'm asking for some advice in case I'm way off base (in particular, aside from the error mentioned I'm concerned about IN params 7-10 being written correctly). Thanks. -Jason --------------------------------- Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less. --0-1032495245-1147661766=:79658 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit I've got a PL/pgSQL stored function in my database and I'm trying to figure out how to call it from my admin script.  Some of the parameters are ArrayList objects of strings and it returns an array that I want to read to determine what the function actually did.  Here is the function header(?):

CREATE OR REPLACE FUNCTION add_thing(
varchar,     -- name:varchar              ($1)
integer,     -- itemNum:integer               ($2)
varchar,     -- owner:varchar           ($3)
varchar,     -- image_url:varchar         ($4)
varchar,     -- specs_url:varchar        ($5)
varchar[],   -- categories[]:varchar           ($6)
varchar[],   -- component_name[]:varchar ($7)
varchar[],   -- component_id[]:varchar   ($8)
date[],      -- component_date[]:date            ($9)
varchar[]    -- componentImage_url[]:varchar   ($10)
) RETURNS varchar[] as '

Here is how I'm trying to call it in Java:

            // Turn transactions off.
            connection.setAutoCommit(false);
            // Procedure call.
            CallableStatement stmt = connection.prepareCall("{ ? = call add_thing( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) }");
            stmt.registerOutParameter(1, Types.ARRAY);
            stmt.setString(2, name);
            stmt.setInt(3, itemNum);
            stmt.setString(4, owner);
            stmt.setString(5, item_url);
            stmt.setString(6, specs);
            stmt.setObject(7, compNames);
            stmt.setObject(8, compIds);
            stmt.setObject(9, compDates);
            stmt.setObject(10, compURL);
            stmt.execute();
            String[] results = stmt.getArray(1);
            stmt.close();

I'm getting a compiler error "Incompatible Types" on the second to last line.  Looking at the API to me it seems like that's how it should work.  I'm thinking of trying getResultSet() instead, but since this is only the compile stage I'm asking for some advice in case I'm way off base (in particular, aside from the error mentioned I'm concerned about IN params 7-10 being written correctly).  Thanks.

-Jason


Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less. --0-1032495245-1147661766=:79658--