pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Issues with IN-OUT parameters for Array of Objects in EDB using Java
10+ messages / 5 participants
[nested] [flat]

* Issues with IN-OUT parameters for Array of Objects in EDB using Java
@ 2012-04-05 14:58  cognizant <sudipbajoria@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: cognizant @ 2012-04-05 14:58 UTC (permalink / raw)
  To: pgsql-jdbc

Hi 

I am having issues with passing IN-OUT Parameters from a function which
returns a array of custom defined objects. I know that the new version(8.X+)
of EDB support nested tables and so was wondering this issue must be faced
by other java developers when trying to use the nested tables. Note I tried
types.Other, Array and STRUCT to register the output nested table object but
didnot work.

*Below is my SQL code*

create or replace
TYPE OT_Ref_Country AS OBJECT (
    countryId       		Integer,
    isoFullName     	Varchar2(256),
    doNotUseIndicator    	Integer
);

create or replace
TYPE NT_Ref_Countries IS TABLE OF OT_Ref_Country;

FUNCTION getCountryList ( ip_countryId IN
Ref_Country.countryid%TYPE,iop_NT_Ref_Countries in out NT_Ref_Countries
) RETURN Number ;


*Java code:*

CallableStatement  st = con.prepareCall("{call
pkg_ref_geography_mgr.getCountryList(4,?)}");
st.registerOutParameter(1,Types.OTHER);
st.execute();


Please let me know if any additional details are needed. The version used is
Postgresql 8.4 with Java6

Tks for the help
-Mike

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Issues-with-IN-OUT-parameters-for-Array-of-Objects-in-EDB-us...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Issues with IN-OUT parameters for Array of Objects in EDB using Java
@ 2012-04-06 11:14  Muhammad Altaf <mmalik_altaf@yahoo.com>
  parent: cognizant <sudipbajoria@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Muhammad Altaf @ 2012-04-06 11:14 UTC (permalink / raw)
  To: cognizant <sudipbajoria@gmail.com>; pgsql-jdbc

UDTs are not yet supported in JDBC driver (using java.sql.Struct or SQLData)

 -- Altaf Malik




________________________________
 From: cognizant <sudipbajoria@gmail.com>
To: pgsql-jdbc@postgresql.org 
Sent: Friday, 6 April 2012 12:58 AM
Subject: [JDBC] Issues with IN-OUT parameters for Array of Objects in EDB using Java
 
Hi 

I am having issues with passing IN-OUT Parameters from a function which
returns a array of custom defined objects. I know that the new version(8.X+)
of EDB support nested tables and so was wondering this issue must be faced
by other java developers when trying to use the nested tables. Note I tried
types.Other, Array and STRUCT to register the output nested table object but
didnot work.

*Below is my SQL code*

create or replace
TYPE OT_Ref_Country AS OBJECT (
    countryId               Integer,
    isoFullName         Varchar2(256),
    doNotUseIndicator        Integer
);

create or replace
TYPE NT_Ref_Countries IS TABLE OF OT_Ref_Country;

FUNCTION getCountryList ( ip_countryId IN
Ref_Country.countryid%TYPE,iop_NT_Ref_Countries in out NT_Ref_Countries
) RETURN Number ;


*Java code:*

CallableStatement  st = con.prepareCall("{call
pkg_ref_geography_mgr.getCountryList(4,?)}");
st.registerOutParameter(1,Types.OTHER);
st.execute();


Please let me know if any additional details are needed. The version used is
Postgresql 8.4 with Java6

Tks for the help
-Mike

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Issues-with-IN-OUT-parameters-for-Array-of-Objects-in-EDB-us...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.

-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Issues with IN-OUT parameters for Array of Objects in EDB using Java
@ 2012-04-06 13:02  cognizant <sudipbajoria@gmail.com>
  parent: Muhammad Altaf <mmalik_altaf@yahoo.com>
  0 siblings, 1 reply; 10+ messages in thread

From: cognizant @ 2012-04-06 13:02 UTC (permalink / raw)
  To: pgsql-jdbc

1. Can I get a list of features not supported/planned
2. Any estimates when will be support for nested table be available?

-Mike

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Issues-with-IN-OUT-parameters-for-Array-of-Objects-in-EDB-us...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Issues with IN-OUT parameters for Array of Objects in EDB using Java
@ 2012-05-15 05:52  jonykapil <jony.kapil@gmail.com>
  parent: cognizant <sudipbajoria@gmail.com>
  0 siblings, 2 replies; 10+ messages in thread

From: jonykapil @ 2012-05-15 05:52 UTC (permalink / raw)
  To: pgsql-jdbc

Hi, This is my first post on the forum. Hope, I'll get a resolution to my
problem. 

We are in process of migration from Oracle 10g to Postgres9.1 Advance
Server. The stored procedures/functions from Oracle have some parameters
registered as Out parameters. Now, when we call it from Java, an exception
thrown -: 

*org.postgresql.util.PSQLException: Malformed function or procedure escape
syntax at offset 9.*

The signature of Postgres Function is as :: 

*sfblprdbilldate(IN p_billdate numeric, IN p_cutoffday numeric, IN
p_billfreq character varying, IN p_givendate timestamp without time zone,
OUT po_startdate timestamp without time zone, OUT po_end_date timestamp
without time zone)*


Java code for calling this function is as follows :: 

  *strSql="{? = call(SFBLPRDBILLDATE(?,?,?,?,?,?))}"; 

                   objCstmt = objConn.prepareCall(strSql); 
                   objCstmt.registerOutParameter(1,Types.VARCHAR); 
                   objCstmt.setInt(2,iBillDay); 
                   objCstmt.setInt(3,iBillDay); 
                   objCstmt.setString(4,strBillFrequency); 
                   objCstmt.setDate(5,dtSysDate); 
                   objCstmt.registerOutParameter(6,Types.DATE); 
                   objCstmt.registerOutParameter(7,Types.DATE); 
                   objCstmt.execute(); 
                   strBillPeriod = objCstmt.getString(1); 
                   dtStartDate   = objCstmt.getDate(6);*Anybody, who has
resolved this sort of issue, please help me as this is in numbers in our
code and we are looking for a solutuin to this problem. 

Thanks 
Jony.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Issues-with-IN-OUT-parameters-for-Array-of-Objects-in-EDB-us...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Re: Issues with IN-OUT parameters for Array of Objects in EDB using Java
@ 2012-05-15 06:06  Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  parent: jonykapil <jony.kapil@gmail.com>
  1 sibling, 1 reply; 10+ messages in thread

From: Heikki Linnakangas @ 2012-05-15 06:06 UTC (permalink / raw)
  To: jonykapil <jony.kapil@gmail.com>; +Cc: pgsql-jdbc

On 15.05.2012 08:52, jonykapil wrote:
> Hi, This is my first post on the forum. Hope, I'll get a resolution to my
> problem.
>
> We are in process of migration from Oracle 10g to Postgres9.1 Advance
> Server.

Advanced Server is EnterpriseDB's proprietary product, while this 
mailing list is for community PostgreSQL. Please contact EnterpriseDB's 
support at support@enterprisedb.com.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Issues with IN-OUT parameters for Array of Objects in EDB using Java
@ 2012-05-15 07:32  jonykapil <jony.kapil@gmail.com>
  parent: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  0 siblings, 1 reply; 10+ messages in thread

From: jonykapil @ 2012-05-15 07:32 UTC (permalink / raw)
  To: pgsql-jdbc

Hello Heikki,
     Thanks for your prompt reply but this function call is simply running
in the Oracle DB and it has nothing specific to the Postgres9.1 Advance
Server. I think this is a generic problem while migration to Postgres9.1 DB.
I hope you will understand the point.
Please help me to sort out this issue.

Thanks
Jony





--
View this message in context: http://postgresql.1045698.n5.nabble.com/Issues-with-IN-OUT-parameters-for-Array-of-Objects-in-EDB-us...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Re: Issues with IN-OUT parameters for Array of Objects in EDB using Java
@ 2012-05-15 09:37  Dave Cramer <pg@fastcrypt.com>
  parent: jonykapil <jony.kapil@gmail.com>
  0 siblings, 0 replies; 10+ messages in thread

From: Dave Cramer @ 2012-05-15 09:37 UTC (permalink / raw)
  To: jonykapil <jony.kapil@gmail.com>; +Cc: pgsql-jdbc

On Tue, May 15, 2012 at 3:32 AM, jonykapil <jony.kapil@gmail.com> wrote:
> Hello Heikki,
>     Thanks for your prompt reply but this function call is simply running
> in the Oracle DB and it has nothing specific to the Postgres9.1 Advance
> Server. I think this is a generic problem while migration to Postgres9.1 DB.
> I hope you will understand the point.
> Please help me to sort out this issue.
>
> Thanks
> Jony


A test case would help.


Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Re: Issues with IN-OUT parameters for Array of Objects in EDB using Java
@ 2012-05-15 10:59  Muhammad Altaf <mmalik_altaf@yahoo.com>
  parent: jonykapil <jony.kapil@gmail.com>
  1 sibling, 1 reply; 10+ messages in thread

From: Muhammad Altaf @ 2012-05-15 10:59 UTC (permalink / raw)
  To: jonykapil <jony.kapil@gmail.com>; pgsql-jdbc

Can you change strSql="{? = call(SFBLPRDBILLDATE(?,?,?,?,?,?))}"; to strSql="{? = call SFBLPRDBILLDATE(?,?,?,?,?,?)}"; 
 Kind Regards
Altaf Malik


________________________________
 From: jonykapil <jony.kapil@gmail.com>
To: pgsql-jdbc@postgresql.org 
Sent: Tuesday, 15 May 2012 3:52 PM
Subject: [JDBC] Re: Issues with IN-OUT parameters for Array of Objects in EDB using Java
 
Hi, This is my first post on the forum. Hope, I'll get a resolution to my
problem. 

We are in process of migration from Oracle 10g to Postgres9.1 Advance
Server. The stored procedures/functions from Oracle have some parameters
registered as Out parameters. Now, when we call it from Java, an exception
thrown -: 

*org.postgresql.util.PSQLException: Malformed function or procedure escape
syntax at offset 9.*

The signature of Postgres Function is as :: 

*sfblprdbilldate(IN p_billdate numeric, IN p_cutoffday numeric, IN
p_billfreq character varying, IN p_givendate timestamp without time zone,
OUT po_startdate timestamp without time zone, OUT po_end_date timestamp
without time zone)*


Java code for calling this function is as follows :: 

  *strSql="{? = call(SFBLPRDBILLDATE(?,?,?,?,?,?))}"; 

                   objCstmt = objConn.prepareCall(strSql); 
                   objCstmt.registerOutParameter(1,Types.VARCHAR); 
                   objCstmt.setInt(2,iBillDay); 
                   objCstmt.setInt(3,iBillDay); 
                   objCstmt.setString(4,strBillFrequency); 
                   objCstmt.setDate(5,dtSysDate); 
                   objCstmt.registerOutParameter(6,Types.DATE); 
                   objCstmt.registerOutParameter(7,Types.DATE); 
                   objCstmt.execute(); 
                   strBillPeriod = objCstmt.getString(1); 
                   dtStartDate   = objCstmt.getDate(6);*Anybody, who has
resolved this sort of issue, please help me as this is in numbers in our
code and we are looking for a solutuin to this problem. 

Thanks 
Jony.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Issues-with-IN-OUT-parameters-for-Array-of-Objects-in-EDB-us...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.

-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Issues with IN-OUT parameters for Array of Objects in EDB using Java
@ 2012-05-15 12:46  jonykapil <jony.kapil@gmail.com>
  parent: Muhammad Altaf <mmalik_altaf@yahoo.com>
  0 siblings, 1 reply; 10+ messages in thread

From: jonykapil @ 2012-05-15 12:46 UTC (permalink / raw)
  To: pgsql-jdbc

Hello Altaf,
      Thanks for your reply.
I changed my calling code as following.

*
objCstmt = objConn.prepareCall("{? = call SFBLPRDBILLDATA(?,?,?, cast(? as
timestamp without time zone),cast(? as timestamp without time zone),cast(?
as timestamp without time zone) )}");

objCstmt.registerOutParameter(1,Types.VARCHAR);
		   objCstmt.setInt(2,iBillDay);
		   objCstmt.setInt(3,iBillDay);
		   objCstmt.setString(4,strBillFrequency);
		   objCstmt.setDate(5,dtSysDate);
		   objCstmt.registerOutParameter(6,Types.DATE);
		   objCstmt.registerOutParameter(7,Types.DATE);
		   objCstmt.execute();*


Exception thrown by Postgres is ::

*org.postgresql.util.PSQLException: ERROR: cannot cast type void to
timestamp without time zone  Position:84*

I am not able to understand why now it is taking registerOutParameter as
void.
Please help me out of this...

Thanks & regards
jony

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Issues-with-IN-OUT-parameters-for-Array-of-Objects-in-EDB-us...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.



^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: Re: Issues with IN-OUT parameters for Array of Objects in EDB using Java
@ 2012-05-16 00:10  Muhammad Altaf <mmalik_altaf@yahoo.com>
  parent: jonykapil <jony.kapil@gmail.com>
  0 siblings, 0 replies; 10+ messages in thread

From: Muhammad Altaf @ 2012-05-16 00:10 UTC (permalink / raw)
  To: jonykapil <jony.kapil@gmail.com>; pgsql-jdbc

Use setTimestamp and no need to cast.

-- Altaf Malik


________________________________
 From: jonykapil <jony.kapil@gmail.com>
To: pgsql-jdbc@postgresql.org 
Sent: Tuesday, 15 May 2012 10:46 PM
Subject: [JDBC] Re: Issues with IN-OUT parameters for Array of Objects in EDB using Java
 
Hello Altaf,
      Thanks for your reply.
I changed my calling code as following.

*
objCstmt = objConn.prepareCall("{? = call SFBLPRDBILLDATA(?,?,?, cast(? as
timestamp without time zone),cast(? as timestamp without time zone),cast(?
as timestamp without time zone) )}");

objCstmt.registerOutParameter(1,Types.VARCHAR);
           objCstmt.setInt(2,iBillDay);
           objCstmt.setInt(3,iBillDay);
           objCstmt.setString(4,strBillFrequency);
           objCstmt.setDate(5,dtSysDate);
           objCstmt.registerOutParameter(6,Types.DATE);
           objCstmt.registerOutParameter(7,Types.DATE);
           objCstmt.execute();*


Exception thrown by Postgres is ::

*org.postgresql.util.PSQLException: ERROR: cannot cast type void to
timestamp without time zone  Position:84*

I am not able to understand why now it is taking registerOutParameter as
void.
Please help me out of this...

Thanks & regards
jony

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Issues-with-IN-OUT-parameters-for-Array-of-Objects-in-EDB-us...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.

-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2012-05-16 00:10 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-04-05 14:58 Issues with IN-OUT parameters for Array of Objects in EDB using Java cognizant <sudipbajoria@gmail.com>
2012-04-06 11:14 ` Muhammad Altaf <mmalik_altaf@yahoo.com>
2012-04-06 13:02   ` cognizant <sudipbajoria@gmail.com>
2012-05-15 05:52     ` jonykapil <jony.kapil@gmail.com>
2012-05-15 06:06       ` Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
2012-05-15 07:32         ` jonykapil <jony.kapil@gmail.com>
2012-05-15 09:37           ` Dave Cramer <pg@fastcrypt.com>
2012-05-15 10:59       ` Muhammad Altaf <mmalik_altaf@yahoo.com>
2012-05-15 12:46         ` jonykapil <jony.kapil@gmail.com>
2012-05-16 00:10           ` Muhammad Altaf <mmalik_altaf@yahoo.com>

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