This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes how to call stored procedure from hibernate that takes array as input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "how to call stored procedure from hibernate that takes array as input" Watch "how to call stored procedure from hibernate that takes array as input" New topic
Author

how to call stored procedure from hibernate that takes array as input

lavnish lalchandani
Ranch Hand

Joined: Feb 28, 2007
Posts: 79
Database Code

CREATE TYPE array_table AS TABLE OF VARCHAR2 (50); -- Array of String
CREATE TYPE array_int AS TABLE OF NUMBER; -- Array of integers

procedure which takes an array as an input parameter and returns an array as its OUT parameter.
below procedure has 2 parameters -
an array of String as its IN parameter – p_array
an array of Integers as OUT parameter – p_arr_int
CREATE OR REPLACE PROCEDURE SchemaName.proc1 (p_array IN array_table,
len OUT NUMBER,
p_arr_int OUT array_int)
AS
v_count NUMBER;
BEGIN
p_arr_int := NEW array_int ();
p_arr_int.EXTEND (10);
len := p_array.COUNT;
v_count := 0;
FOR i IN 1 .. p_array.COUNT
LOOP
DBMS_OUTPUT.put_line (p_array (i));
p_arr_int (i) := v_count;
v_count := v_count + 1;
END LOOP;
END;
/


how can i call this from hibernate using ( i ) Native SQL ( ii ) Named procedure

lavnish.blogspot.com
 
 
subject: how to call stored procedure from hibernate that takes array as input