Testing stored procedures - stupid question

Ok here is a stupid question.. I have a stored procedure that returns 3 refcursors. When I call the procedure from code (C#), everything works fine.. however, I want a way to review the output of the stored procedure in Oracle Sql Developer before I test it in code. I can run it, but I can't figure out a way to display the records in the refcursors, =D

Well I am really looking for syntax help.. sql server developer here, used to things being easier.. here is my procedure signature from running it in sql developer:
DECLARE
CONSUMETYPE NUMBER;
RESULTS SYS_REFCURSOR;
RESULTS2 SYS_REFCURSOR;
RESULTS3 SYS_REFCURSOR;
BEGIN
CONSUMETYPE := NULL;
USP_SELECT_PROMOTIONS(
CONSUMETYPE => CONSUMETYPE,
RESULTS => RESULTS,
RESULTS2 => RESULTS2,
RESULTS3 => RESULTS3
-- Modify the code to output the variable
-- DBMS_OUTPUT.PUT_LINE('RESULTS = ' || RESULTS);
-- Modify the code to output the variable
-- DBMS_OUTPUT.PUT_LINE('RESULTS2 = ' || RESULTS2);
-- Modify the code to output the variable
-- DBMS_OUTPUT.PUT_LINE('RESULTS3 = ' || RESULTS3);
END;
Where it says "Modify the code to output the variables".. It gives me a compile error when uncommenting those lines, and I am assuming because it cannot output a cursor that way, so I am trying to find a way to just output the cursor to a grid or text pane?

Similar Messages

  • How to test Stored Procedure

    I am a MS SQL developer shifting to Oracle PL/SQL...
    I am able to write Stored procedure without problem but don't know how to test it.... Testing is a problem...
    As of now i am asking front end guys to test it, mainly these Stored Procedure are select , insert , update....
    Please help....

    The SQL Developer homepagehas links to demos and tutorials that cover PL/SQL editing and debugging and UnitTesting.
    Sue

  • Testing stored procedure using sql plus

    I'm attempt to create and test a stored procedure in sql plus.
    I enter:
    create procedure sp_getconfiguration(mygroup in char, myparameter in char, myvalue in out char) as begin select configvalue into myvalue from tblconfiguration where configgroup = mygroup and configparameter = myparameter; end;/
    I get a procedure created. response by when I type:
    variable myval char
    call sp_getconfiguration('Language','Enabled', myval);
    I get the following error:
    error at line 1:
    ora-06576: not a valid function or procedure name
    I can go into DBA studio and see the procedure listed and can compile it and it says "valid". I have tried granting execute permission to public and trying it again under sql plus and nothing seems to help.
    I'm also attempting to run this same procedure from VB and get an invalid column name error from there.
    Thanks for any help in advance.
    Lee

    Thanks for all your help. What I actually called product support and they helped me solve it. But what I found out is that if using oracle 8.1.# you have to invoke the stored procedure without the "call " in front of the procedure name. For instance.
    sp_getconfiguation()
    In version 9.# it appears that you use the call in front of the procedure. Dah! So if anyone else is having this problem. That is the solution. Thanks anyway.

  • Help - Stored Procedure/datablock question

    I have a fair understanding, but I'm a bit confused right now. Here' the scenario:
    For performance reasons, I have many tables that I want to load using stored procedures. They are all "look up" tables and don't need to be updated.
    How do I call a stored procedure and populate my datablock?
    Could someone post sample code for the stored procedure and how I integrate that into a data block? THANKS!!!!!
    null

    Bert,
    Create your stored procedures in the database.
    Choose the data block you need populated.
    Select the Data Block Wizard and choose Stored Procedure. Enter the Procedure name as stored in the database, click refresh and you are on your way.
    You will be prompted for each type of operation(the first screen is Select, the next INS, UPD, LOCK). Use the procedures you have defined as appropriate to each screen and Forms does all the work for you. You can define arguments to the procedures if necessary on each of the screens.

  • Unknown Database Connector Error using Oracle stored procedures

    We are using an Oracle database for the first time with our Crystal Reports, and I am attempting to modify a report to use a new stored procedure.  When I attempt to add either the new procedure, or to add a new copy of the existing procedure, I get an error message:
    Unknown Database Connector Error
    If I remove the existing procedure first (leaving no database objects at all), and then attempt to add back exactly the same stored procedure that I just removed, I get a different error message:
    Database Connector Error: '42000:[Oracle][ODBC]Syntax error or access violation'
    Neither of these errors is particularly helpful.  The stored procedure in question works as is.  I can run it in SQL Developer, and it also executes within the existing report if I run it.  Unfortunately, it needs to be modified and given a new name, so I need to be able to add the new stored procedure to the report.
    The operating system is Windows XP Professional version 2002 SP3.  The Oracle version is 11g (11.2.0.2.0).  Crystal reports version is Crystal Reports 2008 (12.3.0.601).  The stored procedure returns a refcursor.  The ODBC connection is created using the "Oracle in OraClient11g_home1" driver.  When I test the connection, it tells me it was successful.
    If it matters, the report is a Saba report.
    Can anyone shed any light on what the problem is and how to fix it.  If the solution is to upgrade the Windows version, that is under the control of our tech support and there is no information available as to when it will happen.

    Yes - I had used the Set Datasource Location to point to the correct ODBC connection.  I get the same results with an existing report as I do with a new blank report.
    I have no idea where the service market place is.  Honestly, I find the entire SAP site confusing.  I found one reference to the PAM guide, but when I clicked on it, it insisted on a userid/password, and apparently the userid/password I have for this discussion group doesn't pass.  I did find, eventually, a document called "Crystal Reports 2008 Service Pack 3 for Windows - Supported Platforms".  When I read it, it tells me that it's compatible with Oracle 11g, generic ODBC, and Windows XP SP3, which is what we are using.  I'm hoping that this document has equivalent information to the PAM guide.

  • Error while executing a stored procedure from forms6i

    When I execute a STORED PROCEDURE from ORACLE DB 10g this procedure works perfectly fine.
    But when I execute the same from the FORMs 6i I get the following error:
    PDE-PLU022 Don't have access to the stored program unit
    XMLPARSERCOVER in schema CARE.
    where XMLPARSERCOVER is the class and
    CARE is the schema.
    Regards,
    Jignesh S

    I have tried this with both the owner of the schema and the intended user, -from both forms and directly.
    All rights was granted on the stored procedure. Since posting I have found that one of the tables that the procedure might insert into, was not explicitly granted to the intended user, and after rectifying that the error message went away.
    -however, the procedure now silently "finishes" without any evidence that it ever ran, if invoked from the forms application. When invoked from SQL Plus (or JDev, or Toad) it runs as expected.
    I have no public synonym for the procedure, -is that necessary?
    The stored procedure in question is implemented in java, and published as a stored procedure. It does rather heavy lifting, when running, using a view against another server , updating local tables and quite a lot of data validation/cleansing, and logging. All recourses are within the same schema.
    Any ideas?

  • Stored Procedure for Crystal Reports

    Hi All,
    I developed this test stored procedure to see wheather we could a stored procedure for crystal reports. It compiled without any problem, but when I run it, it gives me error message. Here is the stored Procedure..
    CREATE OR REPLACE PROCEDURE WOLD1SIM.TEST_PROCEDURE(
    TEST_CURSOR IN OUT TEST_PACKAGE.TEST_TYPE,
    TEST_PARAMETER IN TEST_TABLE.ID%TYPE)
    AS
    BEGIN
    OPEN TEST_CURSOR FOR
    SELECT *
    FROM TEST_TABLE
    WHERE TEST_TABLE.ID = TEST_PARAMETER;
    END TEST_PROCEDURE;
    And
    This is the error message..
    ERROR at line 2:
    ORA-06550: line 2, column 1:
    PLS-00201: identifier 'TEST_PROC' must be declared
    ORA-06550: line 2, column 1:
    PL/SQL: Statement ignored
    I have created the package sucessfully.
    I was wondering If any one of you can advice me where I am making the mistake.
    Thank you

    CREATE OR REPLACE PROCEDURE WOLD1SIM.TEST_PROCEDURE(TEST_CURSOR IN OUT TEST_PACKAGE.TEST_TYPE,
                                                         TEST_PARAMETER IN TEST_TABLE.ID%TYPE)
    ...you have 2 parameters in your procedure WOLD1SIM.TEST_PROCEDURE(). you should also use two parameters when you execute the procedure.

  • How to call a stored procedure that use a type defined in a package?

    Hi all,
    this is stored procedure:
    GET_GIORNATAEVENTO( in_nome_servizio IN VARCHAR2,
    out_dati_aggiornati OUT TAB_VARCHAR2);
    TAB VARCHAR2 is defined in the package specification:
    TYPE tab_varchar2 IS TABLE OF VARCHAR2(5) INDEX BY BINARY_INTEGER;
    and this is the name of the package: PKG_SERVIZI_MMSPUSH.
    This is my php script:
    <?php
    // Connect to database...
    $c=OCILogon("venus_vfl", "venus_vfl", "venvi");
    if ( ! $c ) {
    echo "Connessione non riuscita: " . var_dump( OCIError() );
    die();
    echo "<br>PKG_SERVIZI_MMSPUSH.GET_GIORNATAEVENTO</br> ";
    echo "<br> </br>";
    // Call database procedure...
    $in_servizio = "MOTO";
    $s = OCIParse($c, "begin PKG_SERVIZI_MMSPUSH.GET_GIORNATAEVENTO(:bind1, :bind2); end;");
    OCIBindByName($s, ":bind1", $in_servizio);
    OCIBindByName($s, ":bind2", $out_esito);
    OCIExecute($s,OCI_DEFAULT);
    echo "OUT_DATI_AGGIORNATI= " . $out_esito;
    // Logoff from Oracle
    OCILogoff($c);
    ?>
    How to test stored procedure to get the output parameter?
    Thanks in advance.

    Thanks,
    but I need to test stored procedures that uses type defined in the package.
    e.g.
    if I have s.p.
    PROCEDURE get_risultati_squadra
    ( in_squadra IN VARCHAR2,
    out_serie OUT tab_varchar2_5,
    out_tiporisultato OUT tab_varchar2_5,
    out_n_giornata OUT tab_varchar2_5,
    out_squadre OUT tab_varchar2_200,
    out_risultato OUT tab_varchar2_10,
    out_marcatore OUT tab_varchar2_50,
    out_punti OUT tab_varchar2_3,
    out_rimbalzista OUT tab_varchar2_50,
    out_rimbalzi OUT tab_varchar2_3,
    out_esito OUT tab_varchar2_2);
    I have to define every type external to the package, in this case five new TYPE !!
    Is there another way to solve this problem?
    Thanks

  • How to call a stored procedure that has Table Of data types in VB6?

    Hi everyone,
    I need to call a stored procedure that has a Table Of data type as an input parameter (possibly even several Table Of input parameters). I can't seem to find any example of how to do this in VB6 using ODBC. Is this even possible?
    Thanks you!
    Steve

    Thanks,
    but I need to test stored procedures that uses type defined in the package.
    e.g.
    if I have s.p.
    PROCEDURE get_risultati_squadra
    ( in_squadra IN VARCHAR2,
    out_serie OUT tab_varchar2_5,
    out_tiporisultato OUT tab_varchar2_5,
    out_n_giornata OUT tab_varchar2_5,
    out_squadre OUT tab_varchar2_200,
    out_risultato OUT tab_varchar2_10,
    out_marcatore OUT tab_varchar2_50,
    out_punti OUT tab_varchar2_3,
    out_rimbalzista OUT tab_varchar2_50,
    out_rimbalzi OUT tab_varchar2_3,
    out_esito OUT tab_varchar2_2);
    I have to define every type external to the package, in this case five new TYPE !!
    Is there another way to solve this problem?
    Thanks

  • Stored Procedure in mysql 5.0 failure!

    Hi,
    somebody can help me!
    my database is: mysql-5.0.0a-alpha
    the connection driver is:mysql-connector-java-3.1.1-alpha-bin.jar
    I want to test stored procedure of the new feature in MySQL version 5.0. A
    I can call the stored procedure procPara in Window Console as next show,
    but when I run in procTest.java(shown as next),I get error Messages.
    The error is at the line:
    CallableStatement cs=conn.prepareCall("{call procPara(?)}");
    between checkpoint 1 and checkpoint 2
    your answer is highly appreciated!
    from: Nanfei
    mysql> delimiter //
    mysql>
    mysql> CREATE PROCEDURE procPara(IN name varchar(16))
    -> BEGIN
    -> SELECT note FROM kmdoc where username=name;
    -> END
    -> //
    Query OK, 0 rows affected (0.22 sec)
    mysql> call procPara("John")//
    | note |
    | mysql Manul |
    | Office2000 |
    | PDF |
    | PowerPoint Animation Runtime|
    | Office2003 |
    | Test Title |
    | Say Hello |
    7 rows in set (1.16 sec)
    Query OK, 0 rows affected (1.67 sec)
    mysql>
    procTest.java as following:
    package km;
    import java.sql.*;
    public class procTest{
    public static void main(String[] args)throws Exception {
    String driverConnection="jdbc:mysql://localhost/";
    String catalog="mycatloge";
    String user="myname";
    String psw="mypsw";
    String connDbUserPsw=driverConnection+catalog+"?user="+user+"&password="+psw;
    try {
    Class.forName("com.mysql.jdbc.Driver");
    catch (ClassNotFoundException e) {}
    Connection conn = DriverManager.getConnection(connDbUserPsw);
    System.out.println("checkpoint 1");
    CallableStatement cs=conn.prepareCall("{call procPara(?)}");
    System.out.println("checkpoint 2");
    cs.setString(1,"john");
    java.sql.ResultSet rst=cs.executeQuery();
    while(rst.next()){
    String s=rst.getString(1);
    System.out.println(s);
    Messages:
    checkpoint 1
    java.lang.StringIndexOutOfBoundsException: String index out of range: -9
         at java.lang.String.substring(String.java:1480)
         at com.mysql.jdbc.DatabaseMetaData$TypeDescriptor.<init>(DatabaseMetaData.java:7031)
         at com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:6615)
         at com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:2637)
         at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:904)
         at com.mysql.jdbc.CallableStatement.<init>(CallableStatement.java:72)
         at com.mysql.jdbc.Connection.prepareCall(Connection.java:999)
         at com.mysql.jdbc.Connection.prepareCall(Connection.java:978)
         at km.procTest.main(procTest.java:17)
    Exception in thread "main"
    -------------------------------------------------------------------------

    I got the answer from the following Link:
    Use a nightly snapshot of Connector/J 3.1 from
    http://downloads.mysql.com/snapshots.php
    I replace the old connection driver mysql-connector-java-3.1.1-alpha-bin.jar
    with the more new driver mysql-connector-java-3.1-nightly-20040408-bin.jar
    which I believe is not the final one!
    Now ,Stored Procedure with parameter in mysql 5.0 work ok!

  • Debugger gets hanged on call to stored procedure

    We are using Forms 6i Patch 12.
    The Forms Debugger is getting hanged whenever it encounters a line making a call to stored procedure.
    In earlier versions, we debugger used to "Step Over" instead of allowing a "Step into" on such statements.
    Any Solutions will be appreciated!

    We are working like that.
    Even on new stored procedures, the debugger is getting hanged whether we do any stepping around that line or not.
    There appears to be something wrong with debugger or its settings. It is ok for us if it does not allow "Step Into" in a stored procedure as we can put it as local program unit if any step into is required.
    However, for already tested stored procedures, we can have a step over.
    We do not want to copy all the stored procedures being used in a form as local program units just because the debugger gets hanged whenever it sees a call to stored procedure irrespective of a "Step over", "Step Into" or "Go".
    The problem is how to prevent the debugger from getting hanged.
    Regards,
    Sanjiv

  • Invalid Month error in stored procedure

    Hello, I have a simple stored procedure that I pass a begin and end date into and it is complaining about the date formatting. Below is the table layout and stored procedure in question. How can I format the date for example as MM-DD-YYYY and not have it complain? I have tried using TO_DATE and TO_CHAR and it still complains.
    Thank you.
    -- Table
    CREATE TABLE INV_MOVE_ARCHIVE
    *( "RETAILER_ID" NUMBER NOT NULL,*
    *"SKU_ID" VARCHAR2(18 BYTE) NOT NULL,*
    *"OUTLET_ID" VARCHAR2(20 BYTE) NOT NULL,*
    *"QTY_CHANGE" NUMBER NOT NULL,*
    *"TRANS_DATE" DATE DEFAULT sysdate*
    -- Stored procedure
    CREATE OR REPLACE PROCEDURE inv_move_update(beginDate IN DATE, endDate IN DATE, retailerId IN INT)
    IS
    skuId VARCHAR(18);
    outletId VARCHAR(20);
    qtyChange INTEGER;
    -- Declaring the cursor
    CURSOR getInvRecord IS
    SELECT
    sku_id,
    outlet_id,
    qty_change
    INTO
    skuId,
    outletId,
    qtyChange
    FROM
    inv_move_archive
    WHERE
    retailer_id = retailerId AND
    trans_date &gt;= beginDate AND
    trans_date &lt;= endDate;
    BEGIN
    FOR rec_getInvRecord IN getInvRecord LOOP
    UPDATE OUTLET_SKU_XREF
    SET qty = qty + qtyChange
    WHERE outlet_id = outletId
    AND sku_id = skuId;
    COMMIT;
    END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    IF getInvRecord%isopen THEN CLOSE getInvRecord;
    END IF;
    END inv_move_update;
    */*

    Okay, I do not wantto change the table. I believe thatthe Java developers will need to change their code to call this procedure correctly. Another iss I am having is when I call this procedure manually from the database is is NOT doing the update. I put some debug statements in it and they indicate that the update statement is NOT updating any rows. If I run the select statement that is in the sp using the same parameters I pass into the sp it comes back with 1 row. The row to be updated is present in the table being updated.
    -- Here is my sp call
    DECLARE
      BEGINDATE DATE;
      ENDDATE DATE;
      RETAILERID NUMBER;
    BEGIN
      BEGINDATE := to_date('01/07/2009 00:00:00', 'MM/DD-YYYY HH24:MI:SS');
      ENDDATE := to_date('01/07/2009 11:59:59', 'MM/DD-YYYY HH24:MI:SS');
      RETAILERID := 104;
      INV_MOVE_UPDATE(
        BEGINDATE => BEGINDATE,
        ENDDATE => ENDDATE,
        RETAILERID => RETAILERID
    END;
    -- Select statement with same values
    SELECT
       sku_id,
       outlet_id,
       qty_change
    FROM
       inv_move_archive
    WHERE
       retailer_id = 104 AND
       trans_date >= to_date('01/07/2009 00:00:00', 'MM/DD-YYYY HH24:MI:SS') AND
       trans_date <= to_date('01/07/2009 11:59:59', 'MM/DD-YYYY HH24:MI:SS')
    -- Results from select
    036266579804040     9900165     500
    -- Here is the procedure with the debug statements in it.
    CREATE OR REPLACE PROCEDURE inv_move_update(beginDate IN DATE, endDate IN DATE, retailerId IN  INT)
    IS
            skuId VARCHAR(18);
            outletId VARCHAR(20);
            qtyChange NUMBER;
            errorMessage  VARCHAR(2500) := NULL;       
    -- Declaring the cursor
    CURSOR getInvRecord IS
          SELECT
             sku_id,
             outlet_id,
             qty_change
          INTO
             skuId,
             outletId,
             qtyChange
          FROM
             inv_move_archive
          WHERE
             retailer_id = retailerId AND
             trans_date >= beginDate AND
             trans_date <= endDate;
    BEGIN
       FOR rec_getInvRecord IN getInvRecord LOOP
          DBMS_OUTPUT.PUT_LINE('Rows Updated: ' || SQL%ROWCOUNT);
          UPDATE OUTLET_SKU_XREF
           SET qty = qty + qtyChange
          WHERE outlet_id = outletId
                AND sku_id = skuId;
          DBMS_OUTPUT.PUT_LINE('SKUID: ' || skuId);
          DBMS_OUTPUT.PUT_LINE('Rows Updated: ' || SQL%ROWCOUNT);
          COMMIT;       
       END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
        errorMessage := 'Error updating the OUTLET_SKU_XREF table: ' || SQLCODE || ':' || SQLERRM;
        RAISE_APPLICATION_ERROR(-20001,errorMessage);
        DBMS_OUTPUT.PUT_LINE(errorMessage);
        IF getInvRecord%isopen THEN CLOSE getInvRecord;
        END IF;  
    END inv_move_update;
    /I get no errors when running it. The DBMS_OUTPUT shows null for the skuId and 0 for Rows Updated. Like I said I ran the select manually and it returns a row and I see that the row does exist in the target table. Any ideas what is going on here?
    Thank you
    -- David

  • How to Run Stored Procedures from Teststand

    I am trying to get teststand to run an SQL stored procedure but I always get the following error
    Error executing substep 'Post'.
    The following SQL command failed: 'EXECUTE cdt_st_test...'
    Native error code -2147217900 0x80040e14
    Microsoft OLE DB Provider for SQL Server:
    Syntax error or access violation
    It is a test stored procedure that doesn't pass any parameters.
    Which steps must I use and how do I pass parameters.

    I have sussed it now. I was setting the "Command Type" to stored procedure instead of default. I changed it back and did "EXECUTE cdt_st_test" and it works. I have also added the parameters there as well.

  • How to start a stored procedure

    Hello!
    I have a test stored procedure named TEST which just outputs "hello world". I want to execute the procedure from a bash shell using sql*plus, something like that
    linux-shell> sqlplus user/pass@sid "exec test";Using the notation @script-name we can start sql scripts directly from the bash shell using sql*plus. There should be a possibility to start single statements, right?
    Thanks in advance!

    There should be a possibility to start single statements, right?As far as I know no, there is not.
    You can run a sh or bat script that
    1) accepts the sql statement as a parameter
    2) creates a sql file using the statement and, optionally, the exit keyword to quit sqlplus
    3) calls sqlplus and runs the above created file
    Max
    [My Italian Oracle blog| http://oracleitalia.wordpress.com/2010/02/07/aggiornare-una-tabella-con-listruzione-merge/]

  • Speed test: PL/SQL vs. Java Stored Procedures

    I performed tests on these two procedures:
    ===========================================
    // Create a Statement
    Statement stmt = conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    // Query the table
    ResultSet rset = stmt.executeQuery ("select SIFOB, SIFRA_GU from sezko");
    while (rset.next ()) {
    salary = rset.getInt(1);
    rset.updateInt (1, salary + 1);
    salary = rset.getInt(2);
    rset.updateInt (2, salary + 1);
    rset.updateRow();
    } // while
    conn.commit();
    // Close the RseultSet
    rset.close();
    // Close the Statement
    stmt.close();
    ===========================================
    procedure updateTable is
    cursor c_updateTable is select rowid, SIFOB, SIFRA_GU from sezko;
    begin
    for r_updateTable in c_updateTable loop
    update sezko set SIFOB = SIFOB + 1, SIFRA_GU = SIFRA_GU + 1 where rowid = r_updateTable.rowid;
    end loop;
    commit;
    end;
    ===========================================
    First procedure is written in Java (as Java Stored procedure) and second is PL/SQL.
    Java is about 10x slower than PL/SQL code.
    Can you explain bad performance results?
    thank you
    Matic & Ales

    Hi,
    I suppose the problem is not with the connection object,but with make connection to the database for every executeupdate or executeupdaterow called .Similarly for fetching the data from the database you
    can use the fetch size technique.Please check the 8.1.6 Java Developers guide for using this.
    Update Batching(For Batch updates and commits)
    Fetch Size(For Batch fetching)
    Oracle Row Pre-Fetching
    Regards
    Anand
    null

Maybe you are looking for