pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John Smith <mtdragon@spymac.com>
To: pgsql-jdbc@postgresql.org
Subject: problem with returning a table
Date: Mon, 28 Mar 2005 12:29:15 +0300
Message-ID: <4247CE6B.7050704@spymac.com> (raw)

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);



view thread (3+ messages)  latest in thread

Message-ID: <4247CE6B.7050704@spymac.com>
Permalink:  ../4247CE6B.7050704@spymac.com/
Also on:    postgresql.org/message-id/4247CE6B.7050704@spymac.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: mtdragon@spymac.com
  Subject: Re: problem with returning a table
  In-Reply-To: <4247CE6B.7050704@spymac.com>
  References: <4247CE6B.7050704@spymac.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox