SQLException while calling a Stored Procedure in Oracle

Hi all,
I am getting this error while calling a Stored Procedure in Oracle...
java.sql.SQLException: ORA-00600: internal error code, arguments: [12259], [], [
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:207)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:540)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1273)
at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:780)
at oracle.jdbc.driver.OracleResultSet.next(OracleResultSet.java:135)
at StoredProcedureDemo.main(StoredProcedureDemo.java:36)
The Program is ...
import java.sql.*;
public class StoredProcedureDemo {
     public static void main(String[] args) throws Exception {
          Connection con = null;
          ResultSet rs = null;
          Statement st = null;
          CallableStatement cs = null;
          int i;
          try {
               Class.forName("oracle.jdbc.driver.OracleDriver");
               con = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:SHYAM","scott","tiger");
               System.out.println("Got Connection ");
               st = con.createStatement();
               String createProcedure = "create or replace PROCEDURE Get_emp_names (Dept_num IN NUMBER) IS"
                         +" Emp_name VARCHAR2(10);"
                         +" CURSOR c1 (Depno NUMBER) IS"
                         +" SELECT Ename FROM emp WHERE deptno = Depno;"
                         +" BEGIN"
                         +" OPEN c1(Dept_num);"
                         +" LOOP"
                         +" FETCH c1 INTO Emp_name;"
                         +" EXIT WHEN C1%NOTFOUND;"
                         +" END LOOP;"
                         +" CLOSE c1;"
                         +" END;";
               System.out.println("Stored Procedure is \n"+createProcedure);
               i = st.executeUpdate(createProcedure);
               System.out.println("After creating the Stored Procedure "+i);
               cs = con.prepareCall("{call Get_emp_names(?)}");
               System.out.println("After calling the Stored Procedure ");
               cs.setInt(1,20);
               System.out.println("Before executing the Stored Procedure ");
               rs = cs.executeQuery();
               System.out.println("The Enames of the given Dept are ....");
               while(rs.next()) {
                    System.out.println("In The while loop ");
                    System.out.println(rs.getString(1));
          catch (Exception e) {
               e.printStackTrace();
Stored Procedure is ...
create or replace PROCEDURE Get_emp_names (Dept_num IN NUMBER) IS
Emp_name VARCHAR2(10);
CURSOR c1 (Depno NUMBER) IS
SELECT Ename FROM emp WHERE deptno = Depno;
BEGIN
OPEN c1(Dept_num);
LOOP
FETCH c1 INTO Emp_name;
EXIT WHEN C1%NOTFOUND;
END LOOP;
CLOSE c1;
END;
Stored procedure is working properly on sql*plus(Oracle 8.1.5)) editor. But it is not working from a standalone java application. Can anyone please give me a solution.
thanks and regards
Shyam Krishna

The first solution is to not do that in java in the first place.
DDL should be in script files which are applied to oracle outside of java.
Other than I believe there are some existing stored procedures in Oracle that take DDL strings and process them. Your user has to have permission of course. You can track them down via the documentation.

Similar Messages

  • How to call MSSQL stored procedure from oracle database

    MSSQL and Oracle databases are linked thru ODBC link using Oracle HSODBC.
    I can query MSSQL table or view from Oracle Database using standard notation for acessing remote objects schema.object@dblink_name...
    Can anybody give me syntax for calling MSSQL stored procedure thru ODBC database link?
    I tried syntax exec schema.stored_procedure@dblink_name but it doesn't work...i'm getting schema.stored_procedure must be declared error...
    Tnx,in advance!
    Dejan Botica

    Oracle database 10gR2.
    MSSQL2000 database.
    For example query:
    select * from dbo.Tbl_Test@kron@dw_jamnica; works fine...
    ...while for example exec dbo.Test@kron@dw_jamnica;
    reports error:
    ORA-06550: line 1, column 7:
    PLS-00201: identifier 'DBO.TEST@KRON@DW_JAMNICA' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Table Tbl_Test and procedure Test exists in MSSQL instance.
    Regards,
    Dejan

  • Error while calling a stored procedure using SQLJ

    I am calling a stored procedure defined inside a package through a SQLJ script. The first parameter of that procedure is a IN OUT parameter which is used as a ROWID for creating a cursor. That ROWID value is the same for every record in the table, thereby enabling us to create a cursor.
    When I give a hard-coded value as a parameter, I get an error stating that the assignment is not correct as the query is expecting a variable and not a literal. Hence I removed the hard-coded value and included a dymanic value in the SQLJ call.
    String strVal = "A";
    #sql{CALL ASSIGNMENTS_PKG.INSERT_ROW :{strVal},'SALARY_CODE_GROUP','BU',3,105,sysdate,1,sysdate,1,1)};
    Here "ASSIGNMENTS_PKG" is a package name and INSERT_ROW is the procedure.
    When the SQLJ program is run, I get an error stating:
    "PLS-00201: identifier 'A' must be declared"
    I read the error message, but I am not able to understand where I need to give the GRANT permission to.

    If you're using Oracle Provider for OLE DB (OraOLEDB) to execute this stored procedure, you need to set PLSQLRSet attribute. This attribute can be set in registry, connection string, or command object. Please refer to User Documentation for more information.

  • Error while calling a stored procedure with OUT parameter.

    Hi,
    I am trying to call a Stored Procedure(SP) with an OUT parameter(Ref Cursor) from a third party tool. It is called using OLE-DB Data provider. In one database the procedure works fine but when I change the database the procedure call is giving following error.
    Distribution Object:     COM Error. COM Source: OraOLEDB. COM Error message: IDispatch error #3092. COM Description: ORA-06550: line 1, column 7:
         PLS-00306: wrong number or types of arguments in call to 'TEST1'
         ORA-06550: line 1, column 7:
         PL/SQL: Statement ignored.
    I am not able to find as to why is this happening. Please let me know any clues /help to solve this problem.
    Thanks in advance.

    If you're using Oracle Provider for OLE DB (OraOLEDB) to execute this stored procedure, you need to set PLSQLRSet attribute. This attribute can be set in registry, connection string, or command object. Please refer to User Documentation for more information.

  • Calling a stored procedure using Oracle Ole Db provider

    I am looking for an example of syntax used to call a stored procedure from VB.Net using the Oracle OleDB provider. I have been using the Microsoft provider MSDAORA but need to move to the Oracle provider due to upgrade. The syntax used with the MSDAORA provider does not work with the Oracle provider.

    Hi,
    Please refer to the Populate DataSet with Multiple REF Cursors Sample available at the following URL:
    http://otn.oracle.com/sample_code/tech/windows/ole_db/oledb92/index.html
    Check the PopulateProducts method available in the ViewProducts.cs file that call a database stored procedure "getProductsInfo" . This code is written in C# you may want to convert it to VB.NET syntax.
    Thanks,
    Jagriti
    OTN IDC Team.

  • 21700 while calling java stored procedure in 9i

    I create a java stored procedure that takes a varray of a rowtype. When I call that procedure, I get an ora-21700. If I remove the varray from the parameter list, I can call the procedure okay. My goal is to create a generic java procedure that can take a rowtype from any table and create XML. Once I get the oracle.sql.ARRAY into my code, I am okay. I just can't seem to pass it in. I have pasted my code below:
    Java:
    import oracle.sql.*;
    public class test {
    public static String sayHello() {
    return("Hello, World!");
    public static void genXML(oracle.sql.ARRAY a, oracle.sql.CLOB c) throws Exce
    ption {
    c.putString(1,"<test>This is a test!</test>");
    PL/SQL:
    create or replace package mike is
    type dummy_record is varray (1) of dummy%rowtype;
    PROCEDURE GENERATE_XML(i dummy_record, c CLOB);
    FUNCTION SAYHELLO RETURN varchar2;
    end mike;
    show errors
    create or replace package body mike is
    PROCEDURE GENERATE_XML(i dummy_record,c CLOB)
    AS LANGUAGE JAVA
    NAME 'test.genXML(oracle.sql.ARRAY,oracle.sql.CLOB)';
    FUNCTION SAYHELLO RETURN varchar2
    AS LANGUAGE JAVA
    NAME 'test.sayHello() return java.lang.String';
    end mike;
    show errors
    DDL:
    SQL> describe dummy
    Name Null? Type
    USERNAME VARCHAR2(20)
    ID NUMBER
    Test Script:
    declare
    m Mike.dummy_record := Mike.DUMMY_RECORD();
    c CLOB;
    begin
    m.extend;
    select xml into c from t_clob;
    for rec in (select * from dummy)
    LOOP
    m(1) :=rec;
    mike.generate_xml(m,c);
    end loop;
    end;
    And finally, the output:
    declare
    ERROR at line 1:
    ORA-21700: object does not exist or is marked for delete
    ORA-06512: at "MMANGINO.MIKE", line 0
    ORA-06512: at line 10
    Sorry this post is so long, but I wanted it to be complete!
    Mike

    The first solution is to not do that in java in the first place.
    DDL should be in script files which are applied to oracle outside of java.
    Other than I believe there are some existing stored procedures in Oracle that take DDL strings and process them. Your user has to have permission of course. You can track them down via the documentation.

  • Calling SQL Stored Procedure using Oracle Gateway

    Hi
    Do you know how i can call a stored procedure with parameters from Oracle using oracle gateway?

    Don't know which gateway you are using. Only the transparent gateway for SQL Server and Sybase that have support for stored procedures.
    Take a look at case 7 which shows how to do this.
    Rem case7.sql
    Rem
    Rem Copyright (c) Oracle Corporation 2000. All Rights Reserved.
    Rem
    Rem NAME
    Rem case7.sql
    Rem
    Rem DESCRIPTION
    Rem SQL script which executes the demo case7 for the
    Rem Transparent Gateways
    Rem
    Rem NOTES
    Rem The database link GTWLINK should be created before you can
    Rem run this demo file
    Rem
    Rem MODIFIED (MM/DD/YY)
    Rem kpeyetti 11/09/00 - Created
    Rem
    SET ECHO ON
    DROP TABLE LOCAL_GTW_DEPT;
    CREATE TABLE LOCAL_GTW_DEPT (DEPTNO INTEGER, DEPTNAME VARCHAR2(14));
    SELECT * FROM LOCAL_GTW_DEPT;
    DECLARE
    DNAME VARCHAR2(14);
    BEGIN
    "GetDept"@GTWLINK(10,DNAME);
    INSERT INTO LOCAL_GTW_DEPT VALUES (10, DNAME);
    END;
    SELECT * FROM LOCAL_GTW_DEPT;

  • Calling a stored procedure of oracle 8 from java

    hello,
    i made a stored procedure as below in 1 program :
         String url = "jdbc:odbc:rjc1";
         Connection con = DriverManager.getConnection(url,"scott","tiger");
         Statement stmt = con.createStatement();
         String createProc =
              "Create procedure sp1 as select * from items order by iprice desc";
         stmt.executeUpdate(createProc);
    in other program i have a code as below to retrieve the result of stored procedure :
    CallableStatement cs = con.prepareCall("{call sp2}");
         ResultSet rs = cs.executeQuery();
    the error message that i get is SCOTT.SP1 is invalid.
    any help would be great.
    thanx in advance.

    hello :
    1. i created procedure sp2 and called sp2.
    2. sql statement that we created works fine on oracle - sql i have tested the same.
    3. i did not create a separte userid or password in oracle i was using test account scott which is already present in oracle.
    any thoughts please.

  • I am getting ORA-01403: no data found error while calling a stored procedur

    Hi, I have a stored procedure. When I execute it from Toad it is successfull.
    But when I call that from my java function it gives me ORA-01403: no data found error -
    My code is like this -
    SELECT COUNT(*) INTO L_N_CNT FROM TLSI_SI_MAST WHERE UPPER(CUST_CD) =UPPER(R_V_CUST_CD) AND
    UPPER(ACCT_CD)=UPPER(R_V_ACCT_CD) AND UPPER(CNSGE_CD)=UPPER(R_V_CNSGE_CD) AND
    UPPER(FINALDEST_CD)=UPPER(R_V_FINALDEST_CD) AND     UPPER(TPT_TYPE)=UPPER(R_V_TPT_TYPE);
         IF L_N_CNT >0 THEN
              DBMS_OUTPUT.PUT_LINE('ERROR -DUPlicate SI-1');
              SP_SEL_ERR_MSG(5,R_V_ERROR_MSG);
              RETURN;
         ELSE
              DBMS_OUTPUT.PUT_LINE('BEFORE-INSERT');
              INSERT INTO TLSI_SI_MAST
                   (     CUST_CD, ACCT_CD, CNSGE_CD, FINALDEST_CD, TPT_TYPE,
                        ACCT_NM, CUST_NM,CNSGE_NM, CNSGE_ADDR1, CNSGE_ADDR2,CNSGE_ADDR3,
                        CNSGE_ADDR4, CNSGE_ATTN, EFFECTIVE_DT, MAINT_DT,
                        POD_CD, DELVY_PL_CD, TRANSSHIP,PARTSHIPMT, FREIGHT,
                        PREPAID_BY, COLLECT_BY, BL_REMARK1, BL_REMARK2,
                        MCC_IND, NOMINATION, NOTIFY_P1_NM,NOTIFY_P1_ATTN , NOTIFY_P1_ADDR1,
                        NOTIFY_P1_ADDR2, NOTIFY_P1_ADDR3, NOTIFY_P1_ADDR4,NOTIFY_P2_NM,NOTIFY_P2_ATTN ,
                        NOTIFY_P2_ADDR1,NOTIFY_P2_ADDR2, NOTIFY_P2_ADDR3, NOTIFY_P2_ADDR4,
                        NOTIFY_P3_NM,NOTIFY_P3_ATTN , NOTIFY_P3_ADDR1,NOTIFY_P3_ADDR2, NOTIFY_P3_ADDR3,
                        NOTIFY_P3_ADDR4,CREATION_DT, ACCT_ATTN, SCC_IND, CREAT_BY, MAINT_BY
                        VALUES(     R_V_CUST_CD,R_V_ACCT_CD,R_V_CNSGE_CD,R_V_FINALDEST_CD,R_V_TPT_TYPE,
                        R_V_ACCT_NM,R_V_CUST_NM ,R_V_CNSGE_NM, R_V_CNSGE_ADDR1,R_V_CNSGE_ADDR2, R_V_CNSGE_ADDR3,
                        R_V_CNSGE_ADDR4,R_V_CNSGE_ATTN,     R_V_EFFECTIVE_DT ,SYSDATE, R_V_POD_CD,R_V_DELVY_PL_CD,R_V_TRANSSHIP ,R_V_PARTSHIPMT , R_V_FREIGHT,
                        R_V_PREPAID_BY ,R_V_COLLECT_BY ,R_V_BL_REMARK1 ,R_V_BL_REMARK2,R_V_MCC_IND,
                        R_V_NOMINATION,R_V_NOTIFY_P1_NM, R_V_NOTIFY_P1_ATTN, R_V_NOTIFY_P1_ADD1, R_V_NOTIFY_P1_ADD2,
                        R_V_NOTIFY_P1_ADD3, R_V_NOTIFY_P1_ADD4, R_V_NOTIFY_P2_NM, R_V_NOTIFY_P2_ATTN, R_V_NOTIFY_P2_ADD1,
                        R_V_NOTIFY_P2_ADD2, R_V_NOTIFY_P2_ADD3, R_V_NOTIFY_P2_ADD4, R_V_NOTIFY_P3_NM, R_V_NOTIFY_P3_ATTN,
                        R_V_NOTIFY_P3_ADD1, R_V_NOTIFY_P3_ADD2, R_V_NOTIFY_P3_ADD3, R_V_NOTIFY_P3_ADD4,
                        SYSDATE,R_V_ACCT_ATTN,R_V_SCC_IND,R_V_USER_ID,R_V_USER_ID
                        DBMS_OUTPUT.PUT_LINE(' SI - REC -INSERTED');
         END IF;

    Hi,
    I think there is a part of the stored procedure you did not displayed in your post. I think your issue is probably due to a parsed value from java. For example when calling a procedure from java and the data type from java is different than expected by the procedure the ORA-01403 could be encountered. Can you please show the exact construction of the call of the procedure from within java and also how the procedure possible is provided with an input parameter.
    Regards, Gerwin

  • Transaction Issue while calling a stored procedure in osb

    HI all ,
    I have created a wrapper  procedure to call "soa.delete_instances (this procedure will delete the instances from SOA_INFRA schema)" oy locall created user schema(ASG).
    If i execute  the wrapper procedure direclt in SqlDeveloper it's working fine cleaning the instances.
    i have called this procedure in OSB by using the DB adaptor JCA file, the wrapper procedure is executing fine, but not deleting instances from the SOA_INFRA schema.
    any help is apriciated.
    Thanks..

    Maaan, there could be so many reasons for that... just some things to check:
    1. How do you know the stored procedure executes fine? If you didn't get a failure response from a call to JCA, that means nothing.
    2. Do you log the procedure step by step? Did it reach its normal completion? How many rows (it believes) it found/deleted?
    3. What user is the stored procedure executed under from OSB (obviously -- user of the datasource)? Does this user have rights to see/delete those records?
    4. Are you executing the proxy in transaction, and if yes, didn't you get an error that rolled back that transaction?
    and so on, and so forth.
    Vlad
    http://vladimirdyuzhev.com

  • JTA timeout while calling a stored procedure inside a DB Adapter

    Hi All,
    I am wondering if there is a way to increase the timeout interval for the DB Adapter at the BPEL process level than at a global level.
    Thanks,

    If you're using Oracle Provider for OLE DB (OraOLEDB) to execute this stored procedure, you need to set PLSQLRSet attribute. This attribute can be set in registry, connection string, or command object. Please refer to User Documentation for more information.

  • Calling a stored procedure from Reports

    I am trying to call a stored procedure using oracle reports in the afterparameter code. My code is:
    v_ain := sp_get_ain(:P_session_id);
    Can someone help me out by telling what is wrong. I keep getting an error stating that sp_get_ain needs to be declared.?!

    I am creating a function and a stored procedure and calling them
    in afterparameter report trigger.
    -------------------Create function ----------------
    create or replace function get_name( emp_id number) return varchar2 is
    v_name varchar2(20);
    begin
    select name into v_name
    from sample_table
    where employ_id = emp_id ;
    return(v_name); ---------This is the way to return value from function.
    exception
    when no_data_found then
    return('Name not found.');
    when others then
    return('Other error found.');
    end ;
    ==================================================================================
    ------------------------Create procedure ------------------------------------
    create or replace procedure get_name( emp_id number, return_name out varchar2) is
    v_name varchar2(20);
    begin
    select name into v_name
    from sample_table
    where employ_id = emp_id ;
    return_name := v_name ; --Assign out parameter value from procedure.
    exception
    when no_data_found then
    return_name := 'Name not found.';
    when others then
    return_name := 'Other error found.';
    end ;
    ============================================================================
    -----------------Call function and procedure from report ---------------------
    In formula column or any report trigger you can use this code.
    v_function_return_name varchar2(20);
    v_procedure_return_name varchar2(20);
    v_employ_id number(10);
    begin
    v_employ_id := 101 ;
    v_function_return_name := get_name(v_employ_id ); --- call function
    get_name(v_employ_id , v_procedure_return_name ); -- call procedure
    end;
    Here v_function_return_name has same value as v_procedure_return_name,
    these are the values returned from function and procedure.
    --Anita

  • Calling a Stored Procedure with output parameters from Query Templates

    This is same problem which Shalaka Khandekar logged earlier. This new thread gives the complete description about our problem. Please go through this problem and suggest us a feasible solution.
    We encountered a problem while calling a stored procedure from MII Query Template as follows-
    1. Stored Procedure is defined in a package. Procedure takes the below inputs and outputs.
    a) Input1 - CLOB
    b) Input2 - CLOB
    c) Input3 - CLOB
    d) Output1 - CLOB
    e) Output2 - CLOB
    f) Output3 - Varchar2
    2. There are two ways to get the output back.
    a) Using a Stored Procedure by declaring necessary OUT parameters.
    b) Using a Function which returns a single value.
    3. Consider we are using method 2-a. To call a Stored Procedure with OUT parameters from the Query Template we need to declare variables of
    corresponding types and pass them to the Stored Procedure along with the necessary input parameters.
    4. This method is not a solution to get output because we cannot declare variables of some type(CLOB, Varchar2) in Query Template.
    5. Even though we are successful (step 4) in declaring the OUT variables in Query Template and passed it successfully to the procedure, but our procedure contains outputs which are of type CLOB. It means we are going to get data which is more than VARCHAR2 length which query template cannot return(Limit is 32767
    characters)
    6. So the method 2-a is ruled out.
    7. Now consider method 2-b. Function returns only one value, but we have 3 different OUT values. Assume that we have appended them using a separator. This value is going to be more than 32767 characters which is again a problem with the query template(refer to point 5). So option 2-b is also ruled out.
    Apart from above mentioned methods there is a work around. It is to create a temporary table in the database with above 3 OUT parameters along with a session specific column. We insert the output which we got from the procedure to the temporary table and use it further. As soon the usage of the data is completed we delete the current session specific data. So indirectly we call the table as a Session Table. This solution increases unnecessary load on the database.
    Thanks in Advance.
    Rajesh

    Rajesh,
    please check if this following proposal could serve you.
    Define the Query with mode FixedQueryWithOutput. In the package define a ref cursor as IN OUT parameter. To get your 3 values back, open the cursor in your procedure like "Select val1, val2, val3 from dual". Then the values should get into your query.
    Here is an example how this could be defined.
    Package:
    type return_cur IS ref CURSOR;
    Procedure:
    PROCEDURE myProc(myReturnCur IN OUT return_cur) ...
    OPEN myReturnCur FOR SELECT val1, val2, val3  FROM dual;
    Query:
    DECLARE
      MYRETURNCUR myPackage.return_cur;
    BEGIN
      myPackage.myProc(
        MYRETURNCUR => ?
    END;
    Good luck.
    Michael

  • How to Create a Stored Procedure in Oracle

    I try to create a very simple Stored Procedure from Oracle SQL Developer, got the following error. Can someone give me some help on this? I am new on this. Thanks.
    Error(4,1): PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following: := ( ; not null range default character The symbol ";" was substituted for "BEGIN" to continue.
    create or replace PROCEDURE Test
    AS ACCESSTYP_ID ACCESSTYP.ACCESSTYPCD%TYPE
    BEGIN
         SELECT ACCESSTYPCD
         INTO ACCESSTYP_ID
         FROM ACCESSTYP
         WHERE ACCESSTYPCD = 'WWW';
    END;

    I found out I forgot to put ";" after the declare.
    How do I test it call this stored procedure from
    Oracle SQL Developer.
    create or replace PROCEDURE Test_VL
    AS ACCESSTYP_ID
    ACCESSTYP.ACCESSTYPCD%TYPE;
         SELECT ACCESSTYPCD
         INTO ACCESSTYP_ID
         FROM ACCESSTYP
         WHERE ACCESSTYPCD = 'WWW';
    END;in your SQL Developer window just enclosed your procedure with a Begin ... End.
      Begin
        Test_VL;
      End;

  • How to call a stored procedure from servlet?

    Hi all
    We are developing a project in servlet which needs to call a stored procedure in oracle 8i database.How to make a call? Whether can i get any data from the database using STORED PROCEDURE
    THANKS IN ADVANCE
    kamalakannan

    Hello,
    You can do an HTTP call from a store procedure using thre UTL_HTTP package; so you should be able to call your servlet this way.
    See UTL_HTTP documentation
    Regards
    Tugdual Grall

Maybe you are looking for