Who know how to handle pl/sql table return from stored procedure calling from jsp

I have some stored procedure which return pl/sql table (index by table), It is look like an array. how jdbc handle this?
CallableStatement cs = con.prepareCall("EXECUTE bill.getcountry(?,?)");
cs.setInt(1, cid);
cs.registerOutParameter(2, java.sql.Types.VARCHAR);// ARRAY?
ResultSet rs = cs.executeQuery();
Array array = (Array) rs.getObject (1);
ResultSet array_rset = array.getResultSet ();

Not that familiar with the OCI (Oracle Call Interface), but I think this call will be problematic - the OCI deals with SQL data types and not with PL/SQL structures.
The OCI has since Oracle 8i sported an object call interface (see OCI Runtime Environment for Objects for details).
This allows you to use the CREATE TYPE command to create advance user data types - and these are supported by the SQL engine, PL/SQL engine and external languages via the OCI.
So you need to have a look at the Perl-DBI documentation to see how it supports Oracle object types and consider using these. As for internal PL/SQL data structures. These are not supported by the SQL engine and I would expect limited or no support in the OCI for these. Anyway, using SQL data types makes a lot more sense ito flexibility and transparency across languages and environments.

Similar Messages

  • How Create a Global Temporary Table inside a Stored Procedure?

    Hi...
    I need to create a Global Temporary Table inside a Stored
    Procedure....
    I have no idea how to do that....
    Please....if u can send me a sample, send to me....
    Thanks a lot

    there are many ways to do this..
    one u can use dbms_utility package to run ddl statements like
    for ex:
    declare
    t varchar2(200):='order_no';
    v number;
    begin
    --dbms_utility.exec_ddl_statement('select '||t||' into '||v||'
    from
    --ordermaster where rownum=1');
    dbms_utility.exec_ddl_statement('create table cvt(t number)');
    dbms_output.put_line(v);
    end;
    but the actual method(recommended) involves a bit coding using
    dbms_sql package you will find examples on technet or metalink
    to use this package..
    I hope this helps
    Narendra

  • PL/SQL TABLE AS OUT ON PROCEDURE CALL AND JDBCTHIN(NEED HELP

    How can I pass pl/sql record in and out
    and pl/sql tables in out thru a pl/sql procedure using jdbc with
    the zip file of 816classes12.zip...
    I have tried everything I know...
    I know the procedure is working, others are using it with in
    Oracle...
    I need to use the information it generates.
    here is what I have so far...
    try
    Class.forName ("oracle.jdbc.driver.OracleDriver");
    DriverManager.registerDriver (new
    oracle.jdbc.driver.OracleDriver());
    oracle.jdbc.driver.OracleConnection conn =
    (oracle.jdbc.driver.OracleConnection)
    DriverManager.getConnection ("jdbc:oracle:thin:@--","NA","NA");
    // SQL92 SyntaxCallableStatement
    oracle.jdbc.driver.OracleCallableStatement cstmt =
    (oracle.jdbc.driver.OracleCallableStatement)conn.prepareCall
    ("{call cbmd_proposal_PKG.DefaultTerms (?,?,?,?)}" ) ;
    cstmt.setString(1,"5118");
    cstmt.setString(2,"3");
    cstmt.registerOutParameter
    (2,oracle.jdbc.driver.OracleTypes.NUMBER);
    cstmt.registerOutParameter
    (1,oracle.jdbc.driver.OracleTypes.ARRAY,"");
    cstmt.execute();
    catch(Exception e)
    System.err.println(e.toString());
    e.printStackTrace();
    null

    The "X" in the second registerOutParameter is the type name which
    you have created in oracle DB.
    eg. if you have created a nested table
    create Type integer_table is table of number(10);
    then "X" = "INTEGER_TABLE" and it has to be in caps
    and other thing to keep in mind is that it only works with nested
    table or varray and not with pl/sql table.
    Al Pivonka (guest) wrote:
    : How can I pass pl/sql record in and out
    : and pl/sql tables in out thru a pl/sql procedure using jdbc
    with
    : the zip file of 816classes12.zip...
    : I have tried everything I know...
    : I know the procedure is working, others are using it with in
    : Oracle...
    : I need to use the information it generates.
    : here is what I have so far...
    : try
    : Class.forName ("oracle.jdbc.driver.OracleDriver");
    : DriverManager.registerDriver (new
    : oracle.jdbc.driver.OracleDriver());
    : oracle.jdbc.driver.OracleConnection conn =
    : (oracle.jdbc.driver.OracleConnection
    : DriverManager.getConnection
    ("jdbc:oracle:thin:@--","NA","NA");
    : // SQL92 SyntaxCallableStatement
    : oracle.jdbc.driver.OracleCallableStatement cstmt =
    : (oracle.jdbc.driver.OracleCallableStatement)conn.prepareCall
    : ("{call cbmd_proposal_PKG.DefaultTerms (?,?,?,?)}" ) ;
    : cstmt.setString(1,"5118");
    : cstmt.setString(2,"3");
    : cstmt.registerOutParameter
    : (2,oracle.jdbc.driver.OracleTypes.NUMBER);
    : cstmt.registerOutParameter
    (1,oracle.jdbc.driver.OracleTypes.ARRAY,"X");
    : cstmt.execute();
    : catch(Exception e)
    : System.err.println(e.toString());
    : e.printStackTrace();
    : The "X" in the second registerOutParameter is still unknown to
    : me.
    : The JavaDoc for the
    OracleCallableStatement.registerOutParameter
    : is not clear.
    : Can any One help simplify this...
    : Thanks
    null

  • Joining java array with SQL table in a stored procedure

    Hey,
    I am calling a pl/sql stored procedure from a java program passing two arrays (employees) and (departments) as parameters to the procedure. Within the procedure I have stored the arrays in a table of records like this:
    type t_emp_type is record (employee_id number, department_id number);
    type t_emp_tbl_type is table of t_emp_type index by binary_integer;
    Where all elements in employees are stored in the employee_id column and departments are stored in the department_id column. So basically I've got a table like:
    l_employee_tbl t_emp_tbl_type;
    Looped through the arrays and stored the data like:
    for i in 1..p_employees.count loop
    l_employee_tbl(i).employee_id := p_employees(i);
    l_employee_tbl(i).deparment_id := p_departments(i);
    end loop;
    Now I would like to compare my l_employee_tbl with a SQL table in the database. Basically I would like to join my l_employee_tbl table with a SQL table named departments on department_id, returning all department_id:s that was not found in table departments.
    However, it is not possible to select from a user-defined table type. I have also tried to use the table() function and to cast l_employee_tbl, but found out it can't be done with records. And I would really like to use records or some other type where define my PL/SQL data. I know that you should not mix PL/SQL and SQL but in this case I think it is more efficient to try joining these "tables". Does anyone have a solution for this or advice to try something else out? It would be most appreciated.
    Edited by: 963281 on 2012-okt-04 14:25
    Edited by: 963281 on 2012-okt-05 01:53

    963281 wrote:
    I am calling a pl/sql stored procedure from a java program passing two arrays (p_employees) and (p_departments) as parameters to the procedure. Within the procedure I have stored the arrays in a table of records like this:
    type t_emp_type is record (employee_id number, department_id number);
    type t_emp_tbl_type is table of t_emp_type index by binary_integer;Why do you create an associative array?
    Now I would like to compare my l_employee_tbl with a SQL table in the database. Basically I would like to join my l_employee_tbl table with a SQL table named departments on department_id, returning all department_id:s that was not found in table departments. Of course, not possible as the SQL engine does not support PL/SQL user defined types. PL/SQL however support user defined SQL types. Which makes SQL defined types a lot more flexible.
    However, it is not possible to select from a user-defined table type. I have also tried to use the table() function and to cast l_employee_tbl, but found out it can't be done with records. Never mind SQL and PL/SQL - as a generic programming data structure principle. How do you expect being able to cast an associative array (name-value pairs) to a standard array? The two data structures are very different. So I'm puzzled in how you expect to move a non-scalar name-value pair data structure into a non-scalar value only data structure?
    And I would really like to use records or some other type where define my PL/SQL data. Why exactly? If the Java or PL/SQL data structure is populated using SQL data and database data, and wanting to use that data structure in SQL, what is the point? Why pull SQL data into a client data structure at all then - surely it is far more performant and scalable to rather keep that data in the database, and do the joins/selects/filters/etc using SQL?
    There is also the issue of scalability of local data structures in PL/SQL. The PL/SQL engine runs inside an Oracle server process, consuming private process memory on the server. The bigger the data structures used in PL/SQL, the more server memory needs to be allocated to that server process. This does not scale. Especially not if 10 or more such server processes are running the same PL/SQL code and each server needs to grab large chunks of server memory.
    If the data from Java comes from another source (e.g. keyboard, etc), and you need a means of storing this data server-side for use by PL/SQL and SQL. There are 2 basic choices. PL/SQL arrays for smallish amounts of data - and basing these arrays preferable on SQL data types allowing the array to be used by both SQL and PL/SQL engines. If the amount of data is not smallish, then it should be stored in the SQL engine (database) as that is designed for that exact purpose. And if the data is transient, then a GTT (global temp table) structure can be used (and indexed for optimal access).

  • How to handle a number of records in stored procedure?

    i wanna handle a number of records in a stored procedure one by one.
    what should i do?
    can any one give me some sample about the following question?
    Q:
    tb_main,tb_attach are two tables.
    i want to create a procedure to write off a record in tb_main. before do that, i want to write off all records in tb_attach which is related with the record to be written off in tb_main. and a procedure named pr_write_off_attach for writing off a record in tb_attach has been created already.
    what should i do?
    help!!
    null

    Dg.dataProvider.length is the number of records in the ArrayCollection
    Dg.rowCount is the number of visible rows.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • How to convert simple SQL Select statements into Stored Procedures?

    Hi,
    How can I convert following SELECT statement into a Stored Procedure?
    SELECT a.empno, b.deptno
    FROM emp a, dept b
    WHERE a.deptno=b.deptno;
    Thanking in advance.
    Wajid

    stored procedure is nothing but a named PL/SQL block
    so you can do it like this see below example
    SQL> create or replace procedure emp_details is
      2  cursor c1 is SELECT a.empno, b.deptno
      3  FROM scott.emp a, scott.dept b
      4  WHERE a.deptno=b.deptno;
      5  begin for c2 in c1
      6  LOOP
      7  dbms_output.put_line('name is '||c2.empno);
      8  dbms_output.put_line('deptno is ' ||c2.deptno);
      9  END LOOP;
    10  END;
    11  /
    Procedure created.and to call it use like below
    SQL> begin
      2  emp_details;
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> set serveroutput on;
    SQL> /
    empno is 7839
    deptno is 10
    empno is 7698
    deptno is 30
    empno is 7782
    deptno is 10
    empno is 7566
    deptno is 20
    empno is 7654
    deptno is 30
    empno is 7499
    deptno is 30
    empno is 7844
    deptno is 30
    empno is 7900
    deptno is 30
    empno is 7521
    deptno is 30
    empno is 7902
    deptno is 20
    empno is 7369
    deptno is 20
    empno is 7788
    deptno is 20
    empno is 7876
    deptno is 20
    empno is 7934
    deptno is 10Edited by: Qwerty on Sep 17, 2009 8:37 PM

  • How to create a oracle table in PLSQL Stored Procedure ?

    Gurus,
    Any one send the example link to me to create a oracle table through stored procedure ?
    Thanks.
    S

    begin
    EXECUTE IMMEDIATE "CREATE TABLE BLAH (COL1
    NUMBER)";
    nd;By the way, it raises a question as to why you need
    to create a table dynamically?
    Cheers
    Sarma.By the way, you wouldn't use double quotes for execute immediate:
    begin
       EXECUTE IMMEDIATE "CREATE TABLE BLAH (COL1 NUMBER)";
    end;
    Error at line 1
    ORA-06550: line 2, column 22:
    PLS-00114: identifier 'CREATE TABLE BLAH (COL1 NUMBER' too long
    SQL> begin
       EXECUTE IMMEDIATE 'CREATE TABLE BLAH (COL1 NUMBER)';
    end;
    PL/SQL procedure successfully completed.

  • Passing Table Name to Stored Procedure for From Clause

    Is it possible to pass a table name to a stored procedure to be used in the From clause? I have the same task to perform with numerous tables and I'd like to use the same SP and just pass the table name in. Something like this:
    =======================================
    CREATE OR REPLACE PROCEDURE SP_TEST(
    in_TABLE IN VARCHAR2,
    AS
    V_TABLE VARCHAR2(10);
    BEGIN
    V_TABLE := 'st_' || in_TABLE; -- in_TABLE is 2-3 character string
    SELECT some_columns
    INTO some_variables
    FROM V_TABLE
    WHERE some_conditions...;
    END;
    =======================================
    I'm also using the passed table name to assign to variables in the Select and Where clauses. What I'm getting is an error that V_TABLE must be declared. When I hard code the table name, I don't get any errors, even though I'm also using the same method to assign values in the Select and Where clauses.
    Thanks,
    Ed Holloman

    You need to use dynamic SQL whenever you are swapping out object names (tables, columns).
    create or replace procedure sp_test
      (in_table in varchar2)
    is
      -- variables
    begin
      execute immediate 'select a, b, c from st_' || in_table || ' where x = :xval and y = :yval'
         into v_a, v_b, v_c using v_x, v_y;
    end;

  • Passing UDT TABLE of VARCHAR as an Input parameter in Stored procedure call from java

    I have following Type defined at the schema: ident_arr IS TABLE OF VARCHAR2(100) which is type of one of the input parameters. I am able to create oracle.sql.ARRAY object to map it with this UDT before calling my stored procedure from java. When I execute my stored procedure, I get the following error:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'P_PV_WCC_INSERT'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    I have already checked all other parameter types.

    Hello,
    Thank you, guys, for advice. I should have explained calling context before, but what I basically need to do is to see if procedure(arg1, list(record(arg2, arg3))) returns true.
    I see array binding wouldn't fit there nicely. Internal procedure calls would be proc(next(arg1), next(arg2), next(arg3)) - if all these return true, external call should also return true. I would need to make a list of repeating values of arg1 and separate list(record(arg2, arg3)) into separate lists. I would also need to record whether the internal call returns true to deduce whether external call returns true.
    As I see no better way yet, I'll make Oracle procedure proc(arg1, arg2, arg3) and implement a loop in .NET side. If I optimize for performance, I'll probably pack the array of records into string and pass it for Oracle side to parse.
    Regards,
    Aurimas Pranskevicius

  • Handling Empty date value in the stored procedure call

    Hi,
    i am executing a stored procedure having date element, getting below the error for the empty date value.
    can any solve this issue?
    com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'WD_WRAP_PROCESS_APPMT_REQ_PR' (structure 'STATEMENT'): java.text.ParseException: Unparseable date: ""
    Thank You,
    Madhav

    Madhav,
    Can you check if you are sending blank values to the date parameter?
    raj

  • Writing mulitple sql statements in 1 stored procedure

    Hi all, can i know how to create mulitple sql statements in 1 stored procedure??
    Eg the first sql statement will generate few results and my second sql statement will based on the first statement result to execute its second results and my third sql statements will on the second results to generate the final results which will be passed back to jsp pages as a resultset??
    For the time being, i only know how to create a single sql statement in one stored procedure..i had surf through the oracle website but cant find any solution. Can anyone help me?? Samples or links to any website will do.. Thanks alot...

    Hi Irene,
    If I understand your question correctly, then I have already written
    a similar (PL/SQL) stored procedure without any problems.
    However, I do think your question is more suited to the following
    forum:
    http://forums.oracle.com/forums/forum.jsp?id=478021
    I also think it will help others to answer your question if you
    include the following information:
    1. Version of Oracle you are using.
    2. The error message you are getting.
    3. The part of your code that is causing the problem.
    Also, have you looked at the following web sites?
    http://asktom.oracle.com
    http://metalink.oracle.com
    Good Luck,
    Avi.

  • Don't know how to handle this relationship

    I am a college student and am having a hard time wrapping my head around the database I have to work with for a project. The project entails implementing an auto parts application. I have not encountered a relationship like this before. I have linked to a document I made to describe the table. It can be found here: http://91.121.116.152/graph.pdf. There are basically 4 tables in the database. There is 1 table for all the automakers. (MAKER). Then, there are many tables in the form of APL___ where ___ is a column for the MAKER Table. The APL tables contain all the different models and links to the different parts. The column RLINK references RADCRX which contains 16 different columns. Each set of 4 columns contains part numbers that link to a RAD___ (where ___ is a 3 letter abbr for a vendor).
    I've done my best to explain it in English, but I think the document may help. Naturally the assignment is to find parts for a specified car. My problem is how do I do this as effciently as possible? I don't know how to handle a relationship where column name points to a table name, not a column in the table. It could be done with a very long join such as
    SELECT * FROM RADMOD, RADCRX WHERE RADCRX.MOD1=RADMOD.P_NUMBER
    or so on for each column in RADCRX. This doesn't seem right. I thought about doing joins on the tables, but I don't know how to do it. The DB as about 20K records. Does anyone have any insight?

    Try the ff solution if it works:
    1.)Create a union view for APL_ _ _
    create or replace view v_APL_ALL as
    select a.*,'CHE' m_code from APLCHE a
    union all
    select b.*,'TOY' m_code from APLTOY b
    union all
    select b.*,'HON' m_code from APLHON b
    union all
    select c.*,'MIT' m_code from APLMIT c
    2.)Create a view for v_APL_ALL and MAKER
    create or replace view v_APL_ALL_MAKER as
    select a.*,b.M_NUMBER,b.MAKER
    from v_APL_ALL a,MAKER b
    where a.m_code=b.m_code
    3.)Create view for RAD_ _ _
    create or replace view v_RAD_ALL as
    select a.*,'ARS' VENDOR_CODE from RADARS a
    union all
    select b.*,'MOD' VENDOR_CODE from RADMOD b
    union all
    select c.*,'BEH' VENDOR_CODE from RADBEH c
    union all
    select c.*,'DAN' VENDOR_CODE from RADDAN c
    4.) Create a view for v_RAD_ALL and VENDOR
    create or replace view v_RAD_ALL_VENDOR as
    select a.*,b.M_NUMBER,b.MAKER
    from v_RAD_ALL a,VENDOR b
    where a.VENDOR_CODE=b.VENDOR_CODE
    You can now join them & query it.
    Regards,
    Benjie

  • Drive Utility Help Viewer "does not know how to handle selected URL"

    I have Drive Utility 10.5.6, according to . I'm trying to reformat a FAT32 partition on an external drive to Mac OS X Ext. Journaled in preparation for using SuperDuper to back up my Mac HD boot partition. For a time, which seems to have passed, now that erasing the partition has been done. The Disk Utility Help wouldn't work. Instead of putting up topic information, I got a message saying "Help Viewer does not know how to handle selected URL", followed by an reference to an html file that allegedly existed inside a set of folders inside the app. Where, of course, Finder cannot see. Once the erasing was done, Help seems to have come back. I tried Apple Support, but could only get a reference to OS 9 Appleworks macros not working in OS X. No help at all. Is this a question? I don't know. Help is working now. But for a while it was very annoying. It must be one of those little windows glitches that no one ever bothered to fix.

    In order to change a FAT or NTFS formatted drive for use with OS X you will need to do the following:
    Extended Hard Drive Preparation
    1. Open Disk Utility in your Utilities folder.
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Click on the Partition tab in the DU main window.
    3. Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, set the partition scheme to GUID (for Intel Macs) or APM (for PPC Macs) then click on the OK button. Click on the Partition button and wait until the process has completed.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Set the format type to Mac OS Extended (Journaled.) Click on the Options button, check the button for Zero Data and click on OK to return to the Erase window.
    6. Click on the Erase button. The format process can take up to several hours depending upon the drive size.
    If you have an Intel Mac and can partition the drive using GUID then you can have FAT32 and OS X partitions on the same drive.
    As for problems with the Help viewer see:
    In most cases doing the following will restore the Help Viewer:
    1. Trash the following three files, if extant:
    /Home/Library/Preferences/com.apple.help.plist
    /Home/Library/Preferences/com.apple.helpui.plist
    /Home/Library/Preferences/com.apple.helpviewer.plist
    2. Trash the /Home/Library/Caches/com.apple.helpui folder.
    3. Empty the Trash and Restart.
    Visit The XLab FAQs and read the FAQ on the Help Viewer for additional suggestions.

  • I have a problem with mail.  the spelling and grammer check box before sending the messege is no longer there.  I did everything but cannot get it back.  is ther anyone who knows how to get the box with spelling and grammer checks before sending

    i have a problem with mail.  the spelling and grammer check box before sending the messege is no longer there.  I did everything but cannot get it back.  is ther anyone who knows how to get the box with spelling and grammer checks before sending the mail.
    Also the mail is acting very funny by not getting the rules work in a proper method.  Is ther a software to repair mail.

    i did both of them, but still the while sending the mail the diolog box is not showing up and also the spelling and grammer does not do the spelling check. 
    This problem just started for about 3 to 4 days now.  earlier it was working normally.

  • Hello. I am trying to buy to student edition of Acrobat XI-Pro but there isn't a student felt before or after order. Is there anyone who knows how this happens?

    Hello. I am trying to buy to student edition of Acrobat XI-Pro but there isn't a student felt before or after order. Is there anyone who knows how this happens?

    Hi,
    Please refer to the below mentioned article for further information on this.
    Student software discounts, student eligibility | Adobe
    Thank,
    Vikrantt Singh

Maybe you are looking for