Skip site navigation (1) Skip section navigation (2)

problem with returning a table

From: Ejder DAŞKIN <1030515082(at)erciyes(dot)edu(dot)tr>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: problem with returning a table
Date: 2005-03-28 09:23:29
Message-ID: 4247CD11.4060303@erciyes.edu.tr (view raw or flat)
Thread:
Lists: pgsql-jdbc
Hi everybody,

There is a  function that returns a table.  I set out parameter's type 
to  Types.OTHER but When I call the function in java, returning type is 
returned as INTEGER .

Here is the function:

CREATE OR REPLACE FUNCTION sube_getir(int4, "varchar")
 RETURNS SETOF subeler AS
$BODY$
DECLARE
id ALIAS FOR $1;
ad ALIAS FOR $2;
ref record;

BEGIN
   IF (id=0)AND(ad='') THEN
       for ref in SELECT * FROM subeler loop
           RETURN NEXT ref;
       end loop;
       return;

   ELSEIF (ad='') THEN
       for ref in SELECT * FROM subeler WHERE "HESAP_SUBE_ID"=id loop
       return next ref;
        end loop;
        return;
   ELSE
        for ref in SELECT * FROM subeler WHERE "HESAP_SUBE_ADI"=ad loop
       return next ref;
        end loop;
        return;
   END IF;
  END;
$BODY$
 LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION sube_getir(int4, "varchar") OWNER TO postgres;

--------calling function in java:

sc = conn.prepareCall("{ ? = call sube_getir( ? , ? ) }");
           sc.registerOutParameter(1,Types.OTHER);
           sc.setInt(2,4);
           sc.setString(3,"");
           sc.execute();
           rs = (ResultSet)sc.getObject(1);

Responses

pgsql-jdbc by date

Next:From: John SmithDate: 2005-03-28 09:29:15
Subject: problem with returning a table
Previous:From: Kris JurkaDate: 2005-03-28 08:54:18
Subject: Re: [Patch] JDBC3 Blob support

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group