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.

Similar Messages

  • 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;

  • How to call a stored procedure using its package name in Oracle

    hi
    we're doing a JDBC scenario where we call a stored procedure(a.prc) using its package name(b)The stored procedure has In /Out/IN-OUT parameter.
    i have got 2 queries:
    1- How to call the stored procedure using it's package.
    2- How to capture the In/Out parameter in the response.

    hi Prateek
    thanks for the reply.
    However when i tried mapping it to Package.procedure, communication channel throws the error saying that Package.proceudre needs to be declared.
    As i said , the procedure has IN-OUT parameter too.In oracle we need to write a block if we want to read the IN-OUT parameter.
    How to get the IN-OUT parameter in XI?

  • 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.

  • 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.

  • 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

  • How to call java stored procedure using RMI?

    Is it possible to make a call to java stored procedure using RMI. ?
    How can I run the RMI registry on the Oracle Server ?

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Thomas Grounds ([email protected]):
    Is it possible to make a call to java stored procedure using RMI. ?
    In principle it is possible. See the Java-Doc.s of Oracle 8.1.6.
    I have successful granted the java.net.SocketPermissions in my USER_JAVA_POLICY view (see Doc.) Now I was able to use the RMI-Sockets, but following
    failure try to connect to RMI-Object via RMIregistry an Oracle Error occurs
    ORA-03113: end-of-file on communication channel
    and after that my Oracle Connection is closed.
    How can I run the RMI registry on the Oracle Server ?<HR></BLOCKQUOTE>
    I think you do not need the RMI registry on Oracle Server. It should be possible to start the RMI registry wherever you want in your network and access it via the right registry string.
    Ciao
    Margit
    null

  • Calling a Stored Procedure using SSRS Custom Data Processing Extension

    I need SSRS Custom Data Processing Extension to call a stored procedure for my ssrs report. I refered many links regarding this, but i cannot find it. Instead of that there are examples for Data processing extensions that uses XML files and also multiple
    data sources.
    I want Data Processing Extension to call a stored procedure.
    Please Help. Thanks in advance

    Sorry why do you need a Data Processing Extension for that? Cant you directly call the procedure
    from SSRS dataset? Whats the RDBMS which holds this procedure?
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Need an Example for How to call a Stored Procedure using DBAdapter

    Hi
    I am trying to invoke a stored procedure in Oracle Database using DB Adapter. I have successfully invoked and when i try to run it i got the following error.
    oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: Client received SOAP Fault from server : Exception occured when binding was invoked.
    Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'ExecuteScript' failed due to:
    Stored procedure invocation error.
    Error while trying to prepare and execute the RESONANCEDEMO.SP_QUERY API.
    An error occurred while preparing and executing the RESONANCEDEMO.SP_QUERY API. Cause: java.sql.SQLSyntaxErrorException: ORA-00917: missing comma
    ORA-06512: at "RESONANCEDEMO.SP_QUERY", line 7
    ORA-06512: at line 1
    Check to ensure that the API is defined in the database and that the parameters match the signature of the API.
    This exception is considered not retriable, likely due to a modelling mistake.
    To classify it as retriable instead add property nonRetriableErrorCodes with value "-917" to your deployment descriptor (i.e. weblogic-ra.xml).
    To auto retry a retriable fault set these composite.xml properties for this invoke: jca.retry.interval, jca.retry.count, and jca.retry.backoff.
    All properties are integers.
    I am trying to have a Out Parameter in my Procedure. Please provide me an example on how to invoke a Stored Procedure using Out Paramter using DB Adapter.

    Hi,
    It looks more like an Oracle error and not within the DbAdapter.
    Try to test first your procedure from PL/SQL or other developer you are using.
    Arik

  • Crystal Reports can't add stored procedure using Oracle Provider for OLE DB

    Hello,
    I am trying to bind an oracle stored procedure to a crystal report through Visual Studio 2008.
    This oracle stored procedure returns a ref cursor.
    I am using an oracle 11g database (11.2.0.2.0) .
    When I use the Oracle Provider For OLE DB driver to bind the store procedure with the report, I get the following error message:
    Description : ORA -06550 Line 1 Column 7
    PLS 00306 wrong number of types or arguments to the "Strored Procedure Name"
    But When I use the Microsoft OLE DB provider for oracle driver, I can bind the stored procedure to the report successfully .
    I cannot use the Microsoft OLE DB provider for oracle driver because it does not support the CLOB data type which I plan on having the stored procedure return once I can get everything working.
    I have tried setting PLSQLRSET = 1 IN "HKEY_LOCAL_MACHINE\SOFTWARE\KEY_OraDb11g_home1\OLEDB", but that does not seem to work either
    Any assistance would be greatly Appreciated
    My Stored procedure is very simple as the moment (I just need to get it working then I'll add more stuff). Here's what it looks like:
    CREATE OR REPLACE PACKAGE PROMO.PKG_REPORT as
    TYPE OUT_Type IS REF CURSOR;
    procedure Report_ThisReport (
    p_ThisIdField IN number,
    IO_CURSOR IN OUT OUT_Type
    end PKG_REPORT;
    CREATE OR REPLACE PACKAGE BODY PROMO.PKG_REPORT as
    procedure REPORT_ThisReport (
    p_ThisIdField IN number,
    IO_CURSOR IN OUT OUT_Type
    IS
    BEGIN
    OPEN IO_CURSOR FOR
    SELECT ThisField
    FROM ThisTable
    WHERE ThisIdField = p_ThisIdField ;
    END REPORT_ThisReport;
    end PKG_REPORT;
    Edited by: 894988 on Nov 3, 2011 2:45 PM
    Edited by: 894988 on Nov 3, 2011 2:46 PM
    Edited by: 894988 on Nov 3, 2011 2:47 PM

    It seems that some questions posted here on the XE forum are really questions about other Oracle technologies.
    Concretely, for you there is an Oracle Provider for OLE DB Forum that is active and a terrific resource for you to use.
    Oracle Provider for OLE DB
    Cheers!

  • 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.

  • Using Oracle OLE DB provider (with ADO) generates error: ORA-01843 while using date

    Were using OLE DB provider in order to connect to our Oracle 9i database. When executing the following query in a SQL Plus window I will get the correct results:
    SELECT gum_seu_syo_id, seu_userid, seu_first_name, seu_last_name
    From group_user_mapping, security_users
    Where gum_seu_syo_id = seu_syo_id
    and gum_term_date > '8/19/2002'
    and gum_seg_syo_id = 11
    However if will execute the same query from the our application (VB using ADO) I will get the following error:
    ORA-01843: Not a valid month
    Checking with our Oracle DBA we made sure my registry is correct and includes the correct format under HEKY_LOCAL_MACHINE\SOFTWARE\ORACLE\ORACLE_HOME,
    where the key is NLS_DATE_FORMAT (of type REG_EXPAND_SZ) with the value:
    MM/DD/YYYY HH:MI:SS AM
    I also run the following query in a SQL Plus window:
    select sysdate from dual;
    and got the following result:
    08/19/2002 10:27:20 AM
    which shows that the data format is correct.
    Trying to switch between the month and day in the query (put '19/8/2002') worked from the application but generated ORA-01843: Not a valid month in the SQL Plus window.
    Any ideas?

    try using
    to_char function
    for eg.
    select * from emp where to_char(hiredate,'dd/mm/yy') > '20/3/83'.
    Jagriti

  • 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 Parameter using an UDF

    Hi All,
      I have a requirement where I need to use database lookup. In that I am calling the Stored Procedure using UDF. For example sp_flow ., for this I have to pass<INTID> and <USDERID> to get the response.
    I am using the below code to excute this.
    Channel channel = null;                                                   
    Map rowMap = null;                                                        
    DataBaseAccessor accessor = null;                                         
    DataBaseResult resultSet = null;                                          
    String Query = null;   
    //Query ="EXECUTE dbo.sp_flow <INTID> <USERID>;                                                 
    Query = "EXECUTE dbo.sp_flow  \'304\' ,  \'shankar\'  " ;       
      try{                                                                               
    //Determine a channel, as created in the Configuration                    
    channel =                                                                 
    LookupService.getChanne"BS_XXX","CC_XXX_JDBC_Rcv");                                                                               
    //Get a system accessor for the channel. As the call is being made to an  
    DB, an DatabaseAccessor is obtained.                                      
    accessor = LookupService.getDataBaseAccessor(channel);                                                                               
    //Execute Query and get the values in resultset                           
    resultSet = accessor.execute(Query);                                                                               
    for(Iterator rows = resultSet.getRows();rows.hasNext();){                 
    rowMap = (Map)rows.next();                                                                               
    result.addValue((String)rowMap.get("FLOW_ID"));                       
    I am getting the error "Error when calling an adapter by using the communication channel CC_NWLS_TLA_JDBC_Rcv (Party: , Service: BS_MICROSOFT_SQLWLS20DEV_D, Object ID: d30aace599de3cd69548bf145d0724b7) XI AF API call failed. Module exception: (No information available). Cause Exception: 'Error processing request in sax parser: Error when executing statement for table/stored proc. 'table' (structure 'statement'): com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set."
    let me know how do this.
    Regards
    shankar
    Edited by: Shankar on Jun 9, 2009 2:51 PM
    Edited by: Shankar on Jun 9, 2009 3:02 PM

    first of all calling a SP via the lookup API, there is a workaround but it is not at all recommended
    FYI
    /people/arpil.gupta/blog/2008/11/03/workaround-for-jdbc-scenarios - DB Lookup via Stored procedure
    http://help.sap.com/javadocs/NW04S/current/pi/com/sap/aii/mapping/lookup/DataBaseAccessor.html
    The accessor does not support transactional behaviour. Therefore, the method should not be used to execute insert or update statements on the database which can lead to inconsistencies. The accessor should only be used to read data from a database table.

  • Creating and calling stored procedure using jdbc

    When I try to create and call a stored procedure using JDBC a very confusing error message about non-existence of the procedure just created is thrown. Using Informix database (IDS 10). Any pointers to point out what am doing wrong would be great!
    Thanks
    import java.io.FileNotFoundException;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.Scanner;
    public class CreateStoredProc {
    public static void main(String args[]){
    if (0 == args.length)
    return;
    try {
    Class.forName("com.informix.jdbc.IfxDriver");
    Connection conn = DriverManager.getConnection("jdbc:informix-sqli://10.76.244.120:30000/sampledb:INFORMIXSERVER=krisunda;user=root;password=cisco");
    String q = " create procedure runproc() "+
    " define i int; "+
    " let i = 0; "+
    " end procedure; "+
    " execute procedure runproc(); ";
    Statement stmt = conn.createStatement ();
    stmt.execute (q);
    } catch (Exception e) {
    e.printStackTrace();
    The stack trace:
    java.sql.SQLException: Routine (runproc) can not be resolved.
    at com.informix.jdbc.IfxSqli.a(IfxSqli.java:3204)
    at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3518)
    at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2353)
    at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2269)
    at com.informix.jdbc.IfxSqli.executeExecute(IfxSqli.java:2157)
    at com.informix.jdbc.IfxSqli.executeExecute(IfxSqli.java:2132)
    at com.informix.jdbc.IfxResultSet.b(IfxResultSet.java:378)
    at com.informix.jdbc.IfxStatement.a(IfxStatement.java:1299)
    at com.informix.jdbc.IfxStatement.executeImpl(IfxStatement.java:1269)
    at com.informix.jdbc.IfxStatement.c(IfxStatement.java:989)
    at com.informix.jdbc.IfxStatement.execute(IfxStatement.java:875)
    at CreateStoredProc.main(CreateStoredProc.java:37)
    Caused by: java.sql.SQLException
    at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:373)
    at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3523)
    ... 10 more

    DriverManager.getConnection("jdbc:informix-sqli://10.76.244.120:30000/sampledb:INFORMIXSERVER=krisunda;user=root;password=cisco");check with ur sys admin wheather the particular user in the database has >execute privilage(rights) also.i mean execute the SP in the DB level.I guess that a root user will have the enough right.
    String q = " create procedure runproc() "+
    " define i int; "+<" let i = 0; "+
    " end procedure; "+
    " execute procedure runproc(); ";
    Statement stmt = conn.createStatement ();
    stmt.execute (q);Try to use the following code:
    String q = " create procedure runproc() "+
    " define i int; "+
    " let i = 0; "+
    " end procedure; "
    Statement stmt = conn.createStatement ();
    stmt.execute (q);
    q=" execute procedure runproc(); ";
    stmt.execute (q);
    Because maybe the driver failed to precompile your sql once, so that nothing happen.

Maybe you are looking for

  • Oracle 9i Support for multi language is not working.. Giving question mark

    HI, We have an application which uses oracle 9i as the database. Riight now we are supporting only english and there is a requirement to support multiple languages like korean, chineese and japaneese. But we are planning to migrate one part of the ap

  • Why can I not find the primary video setting in Bios so I can change it from integrated to PCIE?

    I have purchased a new video card to add to my computer which has integrated graphics.  When I installed the card I got a blank screen so I removed the card and restarted the computer and entered BIOS in an attempt to change it from integrated to PCI

  • Running FCE on new iMac

    I just purchased one of the new aluminum 20" iMacs and I wanted to use it for editing some video. I am concerned about whether FCE will run on it or not. I read some stuff on the internet and I am not sure if it will or not. Something about the graph

  • Iphoto has reorganized my photos?

    My iPhoto has been organizing my photos where when I add new photos they are added to the bottom in order. After updating my software(i had to get a new hard drive, but everything was backed up) I went and added new photos to my iPhoto and now new ph

  • How to syntax check the source code of custom methos of classes?

    Hi, Experts, I want to check the syntax errors is present or not in methods of classes, to check that is there any function module or classes for that? Thank U, Shabeer Ahmed.