How get a cursor from a store procedure

i have a package with a procedure like this
PACKAGE PKG_TEST IS
TYPE data_cursor IS REF CURSOR;
PROCEDURE PRC_GET_DATA( VAR_ONE IN VARCHAR2, IO_CURSOR OUT data_cursor ) ;
END ;
PACKAGE BODY PKG_TEST IS
PROCEDURE PRC_GET_DATA( VAR_ONE IN VARCHAR2, IO_CURSOR     OUT data_cursor ) IS
MENSAJE VARCHAR2(1000);
CURSOR_AUX DATA_CURSOR;
ERR_NUM NUMBER;
ERR_MSG VARCHAR2(100);
BEGIN
     OPEN CURSOR_AUX FOR
     SELECT ATTRIB1, ATRIB2 FROM TABLE WHERE (CODITION);
IO_CURSOR := CURSOR_AUX;
END PRC_GET_DATA;
END;
and, i have some troubles to call from JSP page...
the java Source is
Connection conn = source.getConnection();
Statment stmt = conn.createStatment();
CallableStatment cs = conn.prepareCall( {CALL PKG_TEST.PRC_GET_DATA( '%') } );
ResultSet rset = cs.executeQuery();
Some can help me?....

I would not know about JAVA call Syntax to Oracle procedure in the code you are showing, Also it is not
the right place for that question. How ever, I can see that your PL/SQL code needs some fixing
before it can compile and run, hence some simple demonstrationSQL> create or replace package test_pkg as
  2  TYPE data_cursor IS REF CURSOR;
  3  PROCEDURE PRC_GET_DATA( VAR_ONE IN VARCHAR2, IO_CURSOR OUT data_cursor);
  4  END;
  5  /
Package created.
-- Please note that you need to put your SQL for ref cursors in single quotes
-- Also look at the passing the WHERE condition to the SQL
SQL> create or replace package body test_pkg as
  2  PROCEDURE PRC_GET_DATA(VAR_ONE IN VARCHAR2, IO_CURSOR OUT data_cursor) IS
  3    l_cursor data_cursor;
  4  BEGIN
  5    OPEN l_cursor for ('SELECT empno, ename from my_emp WHERE '|| VAR_ONE);
  6    IO_CURSOR := l_cursor;
  7  END;
  8  END;
  9  /
Package body created.
-- Then simply use the returned REF CURSOR in any program, I am showing PL/SQL program here
SQL> Declare
  2     myCur test_pkg.data_cursor;
  3     vEmpNum Number;
  4     vEname  Varchar2(20);
  5  Begin
  6     test_pkg.PRC_GET_DATA('Sal > 1000', myCur);
  7     Loop
  8       Fetch myCur into vEmpNum, vEname;
  9       Exit When myCur%NOTFOUND;
10       dbms_output.put_line(vEmpNum || '  ' || vEname);
11     End Loop;
12     Close myCur;
13  End;
14  /
7369  SMITH
7499  ALLEN
7521  WARD
7566  JONES
7654  MARTIN
PL/SQL procedure successfully completed.Might not be exactly what you are looking for, but from Oracle Forum, this is what is relevant.
Good luck,
Sri

Similar Messages

  • Retrieve to forms 6i a ref cursor from a store procedure

    hi, i wanna know how to retrieving to forms 6i a ref cursor or a sys_refcursor from a function or a store procedure.
    i`ll be very gradeful if someone send me the code.
    sorry about my english, the spanish is my native languaje.

    I think you can use procedure similar to this one:
    example:
    My sample table:
    SQL> desc small_perf_table1;
    Name                                      Null?    Type
    COL1                                               NUMBER
    COL2                                               VARCHAR2(10)
    COL3                                               VARCHAR2(1)
    Simple data inside:
    SQL> select col1 from small_perf_table1
      2  where rownum < 10;
          COL1
             1
             2
             3
             4
             5
             6
             7
             8
             9
    9 rows selected.
    Create procedure which return variable sys_refcursor type:
    SQL> CREATE OR REPLACE PROCEDURE proc_cursor_test
      2  (v_cursor OUT sys_refcursor)
      3  IS
      4  BEGIN
      5   OPEN v_cursor FOR select col1 from small_perf_table1 where rownum < 10;
      6  END;
      7  /
    Procedure created.
    And here is code you can write inside forms:
    SQL> DECLARE
      2   type t_cursor IS REF CURSOR;
      3   v_cursor t_cursor;
      4   v_col1 NUMBER;
      5  BEGIN
      6   proc_cursor_test(v_cursor);
      7   LOOP
      8     FETCH v_cursor INTO v_col1;
      9     EXIT WHEN v_cursor%NOTFOUND;
    10     -- DBMS_OUTPUT.PUT_LINE(v_col1); This line is only for testing inside SQL*PLUS.
    11   END LOOP;
    12  END;
    13  /
    1
    2
    3
    4
    5
    6
    7
    8
    9
    PL/SQL procedure successfully completed.This is just an example.
    If this example does not resolve your problems then maybe you should ask your question on forms forum.
    Forms
    Peter D.

  • Return package cursor from another store procedure

    Hello
    I’m new in Oracle, and I have the following problem:
    I have an cursor in a package defined like that:
    create or replace
    PACKAGE "TestPACKAGE" AS
    cursor DOWNLOAD_CURSOR is select A.* from Table1 A, Table2 B
    END TestPACKAGE;
    In reality there is more than one package with different cursors. I want to use that DOWNLOAD_CURSOR in a store procedure, function or another package, to return it to the client as a ref cursor.
    Something likes that:
    create or replace
    procedure aa_test (retCURSOR OUT sys_refcursor) is
    begin
    retCURSOR := TestPACKAGE.DOWNLOAD_CURSOR;
    end;
    or to replace that procedure with another method to return data, and use them in a .NET application.

    961449 wrote:
    Hello
    I’m new in Oracle, and I have the following problem:
    I have an cursor in a package defined like that:
    create or replace
    PACKAGE "TestPACKAGE" AS
    cursor DOWNLOAD_CURSOR is select A.* from Table1 A, Table2 B
    END TestPACKAGE;
    In reality there is more than one package with different cursors. I want to use that DOWNLOAD_CURSOR in a store procedure, function or another package, to return it to the client as a ref cursor.
    Something likes that:
    create or replace
    procedure aa_test (retCURSOR OUT sys_refcursor) is
    begin
    retCURSOR := TestPACKAGE.DOWNLOAD_CURSOR;
    end;
    or to replace that procedure with another method to return data, and use them in a .NET application.Static PL/SQL cursor declarations and Ref Cursors are not interchangable. You cannot return the static cursor definition as a ref cursor.
    See...
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    v_rc sys_refcursor;
      3    cursor cur_emp is select * from emp;
      4  begin
      5    open v_rc for cur_emp;
      6* end;
    SQL> /
      open v_rc for cur_emp;
    ERROR at line 5:
    ORA-06550: line 5, column 17:
    PLS-00320: the declaration of the type of this expression is incomplete or malformed
    ORA-06550: line 5, column 3:
    PL/SQL: Statement ignored

  • How to get an UPDATABLE REF CURSOR from the STORED PROCEDURE

    using C# with
    ORACLE OLE DB version: 9.0.0.1
    ADO version: 2.7
    I returns a REF CURSOR from a stored procedure seems like:
    type TCursor is ref cursor;
    procedure test_out_cursor(p_Dummy in varchar, p_Cur out TCursor) is
    begin
         open p_Cur for select * from DUAL;
    end;
    I create an ADO Command object and set
    cmd.Properties["IRowsetChange"].Value = true;
    cmd.Properties["Updatability"].Value = 7;
    cmd.Properties["PLSQLRSet"].Value = 1;
    cmd.CommandText = "{CALL OXSYS.TEST.TEST_OUT_CURSOR(?)}";
    and I use a Recordset object to open it:
    rs.Open(cmd, Missing.Value,
    ADODB.CursorTypeEnum.adOpenStatic,
    ADODB.LockTypeEnum.adLockBatchOptimistic,
    (int) ADODB.CommandTypeEnum.adCmdText +
    (int) ADODB.ExecuteOptionEnum.adOptionUnspecified);
    The rs can be opened but can NOT be updated!
    I saved the recordset into a XML file and there's no
    rs:baseschema/rs:basetable/rs:basecolumn
    attributes for "s:AttributeType" element.
    Any one have idea about this?
    thanks very much

    It is not possible through ADO/OLEDB.
    Try ODP.NET currently in Beta, it is possible to update DataSet created with refcursors. You need to specify your custom SQL or SP to send update/insert/delete.
    As I remember there is a sample with ODP.NET Beta 1 just doing this.

  • So i redeemed my money onto itunes but i wanted to get a game from app store but my money is on itunes how do i get that money on app store?

    so i redeemed my money onto itunes but i wanted to get a game from app store but my money is on itunes how do i get that money on app store?

    Is this in the US store? How much is the credit that you have on your account? How much does the app cost?
    The US store prices do not include the local sales taxes added in the final steps of the sale. If you do not have enough credit to cover the total the system asks for a credit card to cover the remaining balance.

  • How to send an e-mail from a store procedure

    Hi,
    I need to find a way to send an e-mail from an store procedure every time a table is fetched.
    Is there a way to accomplish this task?. The e-mail should only display the rows in the table (no more than 5 rows) on a daily basis.
    Any help or example any of you can provide, it's greatly appreciated.
    Thanks
    Ed

    With Oracle 10g you can use UTL_MAIL to send mails.
    For earlier versions see the sample code on OTN
    http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html
    Use DBMS_JOB to schedule the sending of the mail

  • Get the body of the store procedure

    Hi All,
    THe store procedure is created successfully and I don't know how to get the definition of the store procedure. In MSSQL server I used "sp_helptext <store procedure name>" but I don't know how to get text(description) of the store procedure in ORACLE. Your help is greatly appreciated.
    Thanks,
    JP

    Hi all,
    I ran the following statement to get the body of the store procedure:
    select text from user_source where name = <store procedure>
    and the long text(body of store procedure) is returned back. This store procedure is created with the error message return back as "Warning: Procedure created with compilation errors". So I were wondering why the store procdure is in user_source although the creation of this store procedure is returned an error message as mentioned above. Is there anyway that we can find out if the store procedure is created with the compilation errors.
    Thanks,
    JP

  • Retrieving cursor from a stored procedure

    Hi,
    Is there any means to retrieve a cursor from a stored procedure using java.sql.* package, without using database specific type code like OracleTypes.CURSOR?
    Regards,
    Shalin.

    Hi,
    I had some across this problem some time ago. Although, there is no direct answer to this solution, there is a "kloog" that you can apply.
    Please note that the signature for registerOutParameter(int parameterIndex, int sqlType), and note that where ever sqlType is mentioned it is an int.
    Now JDBC is an interface and the implementation is given by Oracle. So to register an "out" parameter all you have to do is registerOutParameter(1, OracleTypes.CURSOR). It works!
    Or otherwise try and find out what the int value of CURSOR is and replace. This is because not all databases can support returning a "cursor" type, since ORACLE and few other databases have a concept of "STORED PROCEDURE" and PLSQL is specific to ORACLE.
    I hope this helps!
    Cheers,
    John.

  • I have been using my Apple ID in India and recently i moved to Spain and now i can not see my indian apps.it says my apple ID is valid for only spanish store.how to download apps from Indian store being in Spain.

    I have been using my Apple ID in India and recently i moved to Spain and now i can not see my indian apps.it says my apple ID is valid for only spanish store.how to download apps from Indian store being in Spain.

    Did you try to change the location  in Settings/iTunes & AppStore/AppleID -> view Apple ID, log in ->Country/Region -> India?

  • My iTunes says I owe $5.25 for songs that I have already paid for and am not going to pay for again but I want to get some apps from the store and now there's a hold on my account. Who do I talk to get the hold taken off

    I explained it most in my question but I am getting charged double for songs that I have already paid for and am not going to pay for twice because that is messed up. But I want to get some apps from the store and it wont let me because of $5.25. Who can I talk to about resolving this issue?

    You're right, it would have been covered under warranty. But because of the user damage, chances are there's a 200-something dollar fee . If you explain to them that it had a defect previously, they might replace it for you at no charge. **MIGHT**. But they would have to believe that it had a defect previously.

  • HT203200 I HAVE JUST PURCHASED LES MISERABLES FROM THE STORE AND TWO TRACKS DID NOT DOWN LOAD. WHAT CAN I DO AND CAN I GET A REFUND FROM THE STORE OR DELETE ALBUM AND GET THE STORE TO DOWNLOAD AGAIN

    I HAVE JUST PURCHASED LES MISERABLES FROM THE STORE BUT TWO TRACKS DID NOT DOWNLOAD. CAN I GET ANOTHER DOWNLOAD FROM THE STORE OR A REFUND? ALTERNATIVELY CAN I DOWNLOAD THE WHOLE ALBUM AGAIN FREE?

    Try the Store tab in iTunes and Check for Downloads.
    If that doesn't work go to the main itunes store screen in itunes and on teh right side under quick links see if you have a purchased secrion - do the tracks appear there for download?
    Failing that contact support:
    http://www.apple.com/support/itunes/store/

  • HT1689 How do I change from US store to UK Store?

    How do I change from US store to UK store?

    Change App Store
    1. Tap "Settings"
    2. Tap "iTunes & App Stores"
    3.Tap "View Apple ID"
    4. Enter your user name and password.
    5. Tap "Country/Region."
    6. Tap "Change Country/Region"
    7. Select the region where you will be located.
    8. Tap "Done".

  • HT5731 How can i transfer from itunes store USA to australian store

    HOw can i transfer from itunes store USA to AustraliN store

    Change App Store
    1. Tap "Settings"
    2. Tap "iTunes & App Stores"
    3.Tap "View Apple ID"
    4. Enter your user name and password.
    5. Tap "Country/Region."
    6. Tap "Change Country/Region"
    7. Select the region where you are located.
    8. Tap "Done".

  • I got my iphone4 yesterday and when I try to get any apps from apps store I keep getting error 1004 please try later please help th iPhone is brand new!

    I got my iphone4 yesterday and when I try to get any apps from apps store I keep getting error 1004 please try later please help th iPhone is brand new!

    mandyfromhull wrote:
    I got my iphone4 yesterday and when I try to get any apps from apps store I keep getting error 1004 please try later please help th iPhone is brand new!
    Try this link to fix your problem.
    http://forums.macrumors.com/showthread.php?t=949246

  • How do i switch from dutch store to belgium store

    well, that's actually my question...
    how do i switch from dutch store to belgium store?

    Settings > iTunes & App Stores > Apple ID: > View Appe ID > sign in > Change Country / Region.

Maybe you are looking for

  • X3-00 instant messaging -chat not pre-installed

    Recently bought x3-00, but nokia instant messaging (chat) is not preinstalled in it.. any way i can install it??  when i go to the nokia website it says "nokia messaging is preinstalled in your phone"... any suggestions?? thnxs

  • Datamodeler 2.0 PS1 (-2.0.0-584) Domain Bug(?)

    Hi, i have done following steps and LOST ALL DOMAIN SETTINGS FOR ALL ATTRIBUTES IN LOGICAL MODEL !!! 1.) Installed new sddm 2.0 PS1 binaries. 2.) Opened the old model (just logical, no relational models contained) and saved on another location on dis

  • Authorization Check when logon into SAP via ITS

    Hello We have implemented Authorization Check after user have logged on to SAP via ITS in this User Exit SUSR0001. It was working fine in 46C version, but after upgrade to ERP 2005, when user logs on into SAP via ITS, this user exits is ignored, whil

  • Canon S95 raw performance slow.

    I'm very happy that I can use raw files from my Canon S95 in Lightroom 3.3RC but the performance/speed of edits is very slow. As an example, full resolution raw files from my Canon 5D Mark II are about twice as fast to edit. Hopefully with the final

  • Reload softwares 513, help!

    Hi, After 3x wrong password, device wipped and error on screen reload softwares 513 I have been searching an trying for hours now and all the steps described don't work - - installed version software and device - BUT no option available to update sof