Excution of a PL/SQL procedure with CURSOR for big tables

I have prepared a proceudre that uses CURSOR to make a complex query for tables with big number of records, something like 900'000. And the execution failed; ORA-01652:impossible to extend the temporary segment of 64 in the space of storage TEMP.
Any sugestion.

This brings us to the following question: How could I calculate the bytes required by a cursor?. It is a selection of certain fields of very big tables. Let's say that the fields are NUMBER(4), NUMBER(8) and CHAR(2). The fields are in 2 relational tables of 900'000 each. What size is required for a procedure like this.
Your help is really appreciated.

Similar Messages

  • Toplink storedProcedure/funtion + PL/SQL Procedure with cursor

    Hi,
    I am working on Toplink storedProcedure but, I am not getting any output. I go through the Oracle Tutorial but, still I am not getting any alternative.
    please, anyone help out....
    Thanking You,
    regards,
    sufian

    Hello Sufian,
    You seem to have a few threads trying to get a Stored proc working. In How to work with Toplink + PL/SQL Procedure + Cursor
    you mention you get an error when executing, have you gotten past this exception? You may want to turn on TopLink logging to see the statement TopLink is creating and sending to the driver. Please see
    http://www.oracle.com/technology/products/ias/toplink/doc/1013/main/_html/sescfg004.htm
    If you are not familar with how to turn on logging.
    Also, are you able to get results from a stored procedure that returns data instead of a cursor?
    Best Regards,
    Chris

  • Stored procedure with cursor as out parameter

    Can any one help me by showing how to write a procedure with cursor as out parameter and caputuring it in java using jdbc.
    Thanks in advance,
    shravan bharadwaj

    I know that in the SQLJ distribution (which is also downloadable) there is an example in the demo directory called RefCursDemo that shows the SQL code and how to call it - albeit from SQLJ and not JDBC. There may also be a demo in the JDBC distribution, though I am not sure about that.

  • PL/SQL Procedures with the same name

    Hi,
    I have some PL/SQL procedures with the same name but different arguments.
    If I try to catalog the second or third ALBPM always catalogs the first and I don't want to use this. ALBPM only catalogs the first one.
    ALBPM Studio Logs:
    Introspecci?n en curso...
    Agregando procedimiento 'ADM_SGI.UGDIASINOI'
    Agregando procedimiento 'ADM_SGI.UGDIASINOI'
    Agregando procedimiento 'ADM_SGI.UGDIASINOI'
    [Advertencia] No se puede agregar procedimiento 'UGDIASINOI'. Motivo: Duplicar nombre del componente (M?dulo DatabaseRoot.ADM_SGI - Componente UGDIASINOI)..
    [Advertencia] No se puede agregar procedimiento 'UGDIASINOI'. Motivo: Duplicar nombre del componente (M?dulo DatabaseRoot.ADM_SGI - Componente UGDIASINOI)..
    Analizando componentes
    Any solution or idea??
    Thanks!

    I need to retrive data from PL/SQL stored procedures. I am using the DynamicSQL component (2nd workaround) to retrive data from PL/SQL stored procedures. <br><br>
    I am having some problems.<br><br>
    This is the code I am running in Fuego Studio 5.5 SP 11 Build #71108:<br><br>
    dynamicSQL as Fuego.Sql.DynamicSQL<br>
    iterator as Iterator(Any[Any])<br>
    sentence as String<br>
    implname as String<br><br>
    dynamicSQL = Fuego.Sql.DynamicSQL()<br>
    implname = "conexionORBPAU"<br>
    sentence = "var result REFCURSOR; " + <br>
    "exec :result_cursor := pkg_audbpm_bpaasig_indicador.prgetsingle(9999);";<br>
    iterator = executeQuery(DynamicSQL, sentence, implname, inParameters : []);<br><br>
    And, this is the error:<br><br>
    java.sql.SQLException: Falta el parametro IN o OUT en el indice:: 1 <br>
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)<br>      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)<br>
    oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1681)<br>
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3280)<br>
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)<br>
         at fuego.jdbc.FaultTolerantPreparedStatement.executeQuery(FaultTolerantPreparedStatement.java:579)<br>
         at fuegoblock.sql.DynamicSQL.executeQuery(DynamicSQL.java:340)<br>
    ...<br><br>
    This is the code of the PL/SQL in the Oracle DB:<br><br>
    CREATE OR REPLACE PACKAGE PKG_AUDBPM_BPAASIG_INDICADOR IS<br>
    TYPE cursor_type IS REF CURSOR;<br>
         FUNCTION prGetSingle<br>
         (<br>
              p_ID_ASIG_INDICADOR IN NUMBER<br>
         )<br>
         RETURN cursor_type;<br><br>
    END PKG_AUDBPM_BPAASIG_INDICADOR;<br><br>
    is my code OK? Any ideas?<br><br>
    Thanks in advance.<br>

  • Creating Web service for PL/SQL Procedure with Complex Data Types

    I need to created web service for PL/SQL Procedure with Complex Data types like table of records as parameters, how do we map the pl/sql table type parameters with web service, how to go about these?

    Hello,
    When you are creating a service from a Stored Procedure, the OracleAS WS tools will create necessary Java and PL wrapper code to handle the complex types (table of record) properly and make them compatible with XML format for SOAP messages.
    So what you should do is to use JDeveloper or WSA command line, to create a service from your store procedure and you will see that most of the work will be done for you.
    You can find more information in the:
    - Developing Web Services that Expose Database Resources
    chapter of the Web Service Developer's guide.
    Regards
    Tugdual Grall

  • How to call sql procedure with parameter from java

    Hello,
    i am trying to call one sql procedure with two parameters from java.
    the first parameter is In parameter, the second is OUT.
    the return value of this java method should be this second parameter value.
    the following is my java code:
    protected String getNextRunNumber() {
         String runnumber=null;
         String sql = "{call APIX.FNC_SST_EXPORT.GET_NEXT_RUNNUMBER (?,?)}";
    CallableStatement state = null;
    try{
         Connection con= getDatabaseConnection();
         state = con.prepareCall(sql);
         state.setString(1, m_appKeyExport);
         state.registerOutParameter(2,Types.NUMERIC,0);
         state.execute();
    ResultSet resultR = (ResultSet)state.getObject(2);
         while (resultR.next()) {
              runnumber=resultR.getBigDecimal(1).toString();
    catch (SQLException e){System.out.println("You can not get the export next run number properly");}
    return runnumber;
    i got error message like:
    java.lang.ClassCastException: java.math.BigDecimal
    As far as i knew, if the parameter is number or decimal, we should give also the paramer scale to the method: state.registerOutParameter(), but i still get this error message.
    Please help me to solve this problem.
    Thanks a lot.

    state.execute();
    i try to use debug to find the problem, in this line, i saw
    OracleCallableStatement(OraclePreparedStatement).execute() line: 642 [local variables unavailable]
    is this the problem?

  • Using FOR .. LOOP counter in handling of PL/SQL procedures with nest. table

    Hi all!
    I'm learning PL/SQL on Steve Bobrovsky's book (specified below sample is from it) and I've a question.
    In the procedure of specified below program used an integer variable currentElement to get reference to the row of nested table of %ROWTYPE datatype.
    Meanwhile, the program itself uses a common FOR .. LOOP counter i.
    DECLARE
    TYPE partsTable IS TABLE OF parts%ROWTYPE;
    tempParts partsTable := partsTable();
    CURSOR selectedParts IS
      SELECT * FROM parts ORDER BY id;
    currentPart selectedParts%ROWTYPE;
    currentElement INTEGER;
    PROCEDURE printParts(p_title IN VARCHAR2, p_collection IN partsTable) IS
      BEGIN
       DBMS_OUTPUT.PUT_LINE(' ');
       DBMS_OUTPUT.PUT_LINE(p_title || ' elements: ' || p_collection.COUNT);
       currentElement := p_collection.FIRST;
       FOR i IN 1 .. p_collection.COUNT
       LOOP
        DBMS_OUTPUT.PUT('Element #' || currentElement || ' is ');
         IF tempParts(currentElement).id IS NULL THEN DBMS_OUTPUT.PUT_LINE('an empty element.');
         ELSE DBMS_OUTPUT.PUT_LINE('ID: ' || tempParts(currentElement).id || ' DESCRIPTION: ' || tempParts(currentElement).description);
         END IF;
        currentElement := p_collection.NEXT(currentElement);
       END LOOP;
    END printParts;
    BEGIN
    FOR currentPart IN selectedParts
    LOOP
      tempParts.EXTEND(2);
      tempParts(tempParts.LAST) := currentPart;
    END LOOP;
    printParts('Densely populated', tempParts);
    FOR i IN 1 .. tempParts.COUNT
    LOOP
      IF tempParts(i).id is NULL THEN tempParts.DELETE(i);
      END IF;
    END LOOP;
    FOR i IN 1 .. 50
    LOOP
      DBMS_OUTPUT.PUT('-');
    END LOOP;
    printParts('Sparsely populated', tempParts);
    END;
    /When I've substituted an INTEGER global variable with such FOR .. LOOP counter, an APEX have returned an error "ORA-01403: no data found".
    DECLARE
    TYPE partsTable IS TABLE OF parts%ROWTYPE;
    tempParts partsTable := partsTable();
    CURSOR selectedParts IS
      SELECT * FROM parts ORDER BY id;
    currentPart selectedParts%ROWTYPE;
    PROCEDURE printParts(p_title IN VARCHAR2, p_collection IN partsTable) IS
      BEGIN
       DBMS_OUTPUT.PUT_LINE(' ');
       DBMS_OUTPUT.PUT_LINE(p_title || ' elements: ' || p_collection.COUNT);
       FOR i IN 1 .. p_collection.COUNT
       LOOP
        DBMS_OUTPUT.PUT('Element is ');
         IF tempParts(i).id IS NULL THEN DBMS_OUTPUT.PUT_LINE('an empty element.');
         ELSE DBMS_OUTPUT.PUT_LINE('ID: ' || tempParts(i).id || ' DESCRIPTION: ' || tempParts(i).description);
         END IF;
       END LOOP;
    END printParts;
    BEGIN
    FOR currentPart IN selectedParts
    LOOP
      tempParts.EXTEND(2);
      tempParts(tempParts.LAST) := currentPart;
    END LOOP;
    printParts('Densely populated', tempParts);
    FOR i IN 1 .. tempParts.COUNT
    LOOP
      IF tempParts(i).id is NULL THEN tempParts.DELETE(i);
      END IF;
    END LOOP;
    FOR i IN 1 .. 50
    LOOP
      DBMS_OUTPUT.PUT('-');
    END LOOP;
    printParts('Sparsely populated', tempParts);
    END;
    /When I've tried to handle this code in SQL*Plus, the following picture have appeared:
    Densely populated elements: 10
    Element is an empty element.
    Element is ID: 1 DESCRIPTION: Fax Machine
    Element is an empty element.
    Element is ID: 2 DESCRIPTION: Copy Machine
    Element is an empty element.
    Element is ID: 3 DESCRIPTION: Laptop PC
    Element is an empty element.
    Element is ID: 4 DESCRIPTION: Desktop PC
    Element is an empty element.
    Element is ID: 5 DESCRIPTION: Scanner
    Sparsely populated elements: 5
    DECLARE
    ERROR at line 1:                                 
    ORA-01403: no data found                         
    ORA-06512: at line 14                            
    ORA-06512: at line 35What's wrong in code(or what I have not understood)? Help please!

    942736 wrote:
    What's wrong in code(or what I have not understood)? Help please!First code. You have collection of 10 elements:
    1 - null
    2 - populated
    3 - null
    4 - populated
    5 - null
    6 - populated
    7 - null
    8 - populated
    9 - null
    10 - populated
    Then you delete null elements and have 5 element collection
    2 - populated
    4 - populated
    6 - populated
    8 - populated
    10 - populated
    Now you execute:
    printParts('Sparsely populated', tempParts);Inside procedure you execute:
    currentElement := p_collection.FIRST;
    This assingns currentElement value 2. Then procedure loops 5 times (collection element count is 5). Element 2 exists. Inside loop procedure executes:
    currentElement := p_collection.NEXT(currentElement);
    which assigns currentElement values 4,6,8,10 - all existing elements.
    Now second code. Everything is OK until you delete null elements. Again we have:
    2 - populated
    4 - populated
    6 - populated
    8 - populated
    10 - populated
    Again you execute:
    printParts('Sparsely populated', tempParts);Now procedure loops 5 times (i values are 1,2,3,4,5):
    FOR i IN 1 .. p_collection.COUNT
    Very first iteration assingns i value 1. And since collection has no element with substript 1 procedure raises no data found.
    SY.

  • Stored procedure with cursor as output param

    It's the first time for me to test a stored procedure with a cursor as output parameter. I executed the following:
    SQL> VARIABLE user_cur REFCURSOR; VARIABLE ret_code VARCHAR2; exec TEST_API.SEARCH_USER( :ret_code, '', '', 'john', '', :user_cur); print ret_code;print user_cur;
    I got the following error:
    Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
    VARCHAR2 (n CHAR) | NCHAR | NCHAR (n) |
    NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR ] ]
    May I know what's the problem?
    The purpose of the stored procedure is to search for user with the name "john".
    The stored procudure input/output params declaration is as follows:
    PROCEDURE SEARCH_USER
    RETURN_CODE OUT VARCHAR2,
    USER_ID_IN IN VARCHAR2,
    POSITION_IN IN VARCHAR2,
    USERNAME_IN IN VARCHAR2,
    STATUS_IN IN VARCHAR2,
    USER_CUR_OUT OUT REFCURSOR
    Edited by: user7383310 on Oct 19, 2008 9:05 PM
    Edited by: user7383310 on Oct 19, 2008 9:05 PM

    for the usage of refcursors in pl/sql refer here..
    http://download.oracle.com/docs/cd/B14117_01/appdev.101/b10807/06_ora.htm#sthref808
    You can code like..
    SQL> create or replace procedure p1(id number,csr out sys_refcursor) is
      2  begin
      3   open csr for select ename from emp where deptno = id;
      4  end;
      5  /
    Procedure created.
    SQL> var csr1 refcursor
    SQL> var n number
    SQL> exec :n := 30;
    PL/SQL procedure successfully completed.
    SQL> exec p1(:n,:csr1);
    PL/SQL procedure successfully completed.
    SQL> print csr1
    ENAME
    ALLEN
    WARD
    MARTIN
    BLAKE
    TURNER
    JAMES
    6 rows selected.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Running SQL Procedure with dg4msql errors: Function sequence error HY010

    I am trying to execute a stored procedure on a SQL database and get the error Function sequence error HY010.
    A simple query on a table returns teh expected result.
    I have a single Win2008R2 server with MSSQL Express 2008 and Oracle 11gR2 (32bit not 64bit version of Oracle)
    Below is the gateway init, listener and tnsnames files and the query I am trying to run:
    -- initORIONWASP.ora --
    HS_FDS_CONNECT_INFO=INGRDB//waspForGIS
    HS_FDS_TRACE_LEVEL=OFF
    HS_FDS_RECOVERY_ACCOUNT=RECOVER
    HS_FDS_RECOVERY_PWD=RECOVER
    HS_CALL_NAME=dbo.spTest;dbo.spQueryAsset;dbo.spQueryAssetDetails
    HS_FDS_PROC_IS_FUNC=TRUE
    HS_FDS_RESULTSET_SUPPORT=TRUE
    -- Listener.ora -- (partial)
    (SID_DESC =
    (SID_NAME = ORIONWASP)
    (ORACLE_HOME = C:\Oracle\product\11.2.0\dbhome_1)
    (PROGRAM=dg4msql)
    -- tnsnames.ora -- (partial)
    ORIONWASP =
    (DESCRIPTION=
    (ADDRESS=(PROTOCOL=tcp)(HOST=INGRDB)(PORT=1521))
    (CONNECT_DATA=(SID=ORIONWASP))
    (HS=OK)
    -- Simple Query --
    Running select "Asset_ID" from asset@ORIONWASP; returns the correct result
    Running select * from sys.procedures@ORIONWASP; returns a list of procedures including the procedure I want to run
    -- This pl/sql block returns the error ******* identifier 'spTest@ORIONWASP' must be declared *******
    declare
    begin
    "spTest"@ORIONWASP;
    end;
    -- This passthrough pl/sql block returns ******** [Oracle][ODBC SQL Server Driver]Function sequence error {HY010} ********
    DECLARE
    CRS BINARY_INTEGER;
    RET BINARY_INTEGER;
    v_COL1 VARCHAR2(50);
    v_COL2 VARCHAR2(50);
    BEGIN
    CRS := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@ORIONWASP;
    DBMS_HS_PASSTHROUGH.PARSE@ORIONWASP(CRS, 'exec spTest');
    BEGIN
    RET := 0;
    WHILE (TRUE)
    LOOP
    ret := DBMS_HS_PASSTHROUGH.FETCH_ROW@ORIONWASP(CRS, FALSE);
    DBMS_HS_PASSTHROUGH.GET_VALUE@ORIONWASP(CRS, 1, v_COL1);
    DBMS_HS_PASSTHROUGH.GET_VALUE@ORIONWASP(CRS, 2, v_COL2);
    DBMS_OUTPUT.PUT_Line('Col1:'||v_COL1||' Col2:'||v_COL2);
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    BEGIN
    DBMS_OUTPUT.PUT_LINE('End of Fetch');
    DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@ORIONWASP(CRS);
    END;
    END;
    END;
    /

    The gateway configuration file contains:
    HS_FDS_PROC_IS_FUNC=TRUE
    HS_FDS_RESULTSET_SUPPORT=TRUE
    This setting commonly causes problems and you need to set
    HS_FDS_PROC_IS_FUNC=TRUE
    HS_FDS_RESULTSET_SUPPORT=FALSE
    for normal procedure calls and
    HS_FDS_PROC_IS_FUNC=FALSE
    HS_FDS_RESULTSET_SUPPORT=TRUE
    when calling the procedure with ref cursors.
    There's a note in My Oracle Support that gives you examples how to call remote SQl Server procedures
         Note.197192.1 Different Methods How To Call MS SQL Server Procedures Using TG4MSQL - DG4MSQL
    and another one for the Sybase gateway but this code is similar for the SQL Server:
    Article-ID: Note 351400.1
    Title: How to Call a Remote Sybase Procedure Using TG4SYBS

  • Debugging PL/SQL procedures with JDeveloper ?

    Hi,
    does anyone know if it is possible to debug PL/SQL procedures and packages with JDeveloper ? I'm using a 9.0.1.2.0 database but JDeveloper returns the error "The target VB_TEST could not be started because the database version does not support debugging." when I try to debug a PL/SQL procedure.
    If it is not possible, does anyone know a good alternative ?Oracle Script Debugger is not available anymore at technet.

    I need to retrive data from PL/SQL stored procedures. I am using the DynamicSQL component (2nd workaround) to retrive data from PL/SQL stored procedures. <br><br>
    I am having some problems.<br><br>
    This is the code I am running in Fuego Studio 5.5 SP 11 Build #71108:<br><br>
    dynamicSQL as Fuego.Sql.DynamicSQL<br>
    iterator as Iterator(Any[Any])<br>
    sentence as String<br>
    implname as String<br><br>
    dynamicSQL = Fuego.Sql.DynamicSQL()<br>
    implname = "conexionORBPAU"<br>
    sentence = "var result REFCURSOR; " + <br>
    "exec :result_cursor := pkg_audbpm_bpaasig_indicador.prgetsingle(9999);";<br>
    iterator = executeQuery(DynamicSQL, sentence, implname, inParameters : []);<br><br>
    And, this is the error:<br><br>
    java.sql.SQLException: Falta el parametro IN o OUT en el indice:: 1 <br>
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)<br>      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)<br>
    oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1681)<br>
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3280)<br>
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)<br>
         at fuego.jdbc.FaultTolerantPreparedStatement.executeQuery(FaultTolerantPreparedStatement.java:579)<br>
         at fuegoblock.sql.DynamicSQL.executeQuery(DynamicSQL.java:340)<br>
    ...<br><br>
    This is the code of the PL/SQL in the Oracle DB:<br><br>
    CREATE OR REPLACE PACKAGE PKG_AUDBPM_BPAASIG_INDICADOR IS<br>
    TYPE cursor_type IS REF CURSOR;<br>
         FUNCTION prGetSingle<br>
         (<br>
              p_ID_ASIG_INDICADOR IN NUMBER<br>
         )<br>
         RETURN cursor_type;<br><br>
    END PKG_AUDBPM_BPAASIG_INDICADOR;<br><br>
    is my code OK? Any ideas?<br><br>
    Thanks in advance.<br>

  • Select clause inside a Procedure with cursor

    Good Moring guys,
    I run into a problem that is giving me serious troubles.... I have a Select clause:
                  SELECT count(*)
                 FROM TD004_ENT_ORGAO_UO TD004
                 WHERE TD004.CODG_ENTIDADE = 1121742
                 AND TD004.NUMR_ANO_EXERCICIO = 2011
                 AND TD004.CODG_ORGAO = 02
                 AND TD004.CODG_UO = 001
    My table is empty and this query returns a count = 0, so far so good but, when I'm using this same query inside a Procedure that implements a cursor, I'm implementing a way of controling when to or not insert the records of this cursor in my table:
    OPEN cDIMENSAO;
    LOOP
           FETCH cDIMENSAO INTO EXERCICIO, CODG_ORGAO, NOME_ORGAO, CODG_UO, NOME_UO, CODG_ENTIDADE, SK_ENTIDADE;
           EXIT WHEN cDIMENSAO%NOTFOUND;
           begin
                 v_count := 0;
                 SELECT count(*) into V_COUNT
                 FROM TD004_ENT_ORGAO_UO TD004
                 WHERE TD004.CODG_ENTIDADE = CODG_ENTIDADE
                 AND TD004.NUMR_ANO_EXERCICIO = EXERCICIO
                 AND TD004.CODG_ORGAO = CODG_ORGAO
                 AND TD004.CODG_UO = CODG_UO;
                 IF V_COUNT = 0 THEN
                    INSERT INTO APLIC.TD004_ENT_ORGAO_UO(SK_ENT_ORGAO_UO, NUMR_ANO_EXERCICIO, CODG_ORGAO, NOME_ORGAO, CODG_UO, NOME_UO, CODG_ENTIDADE, SK_ENTIDADE, DATA_CARGA)
                    VALUES (APLIC.SK004_ENT_ORGAO_UO.NEXTVAL, EXERCICIO, CODG_ORGAO, NOME_ORGAO, CODG_UO, NOME_UO,CODG_ENTIDADE,SK_ENTIDADE,v_data_carga);
                    COMMIT;
                 END IF;
    The problem occurs here, my v_count controler just returns 1 even if the record isnt inside my table, is like the Where clasue is being ignored. What can be done ??
    I'm using the Oracle XE 11g.
    Thnks all.

    See below. Where clause will never ignore any condition
    Note: you need handle null values  specially
    SQL>
    SQL> select * from v$version;
    BANNER                                                                         
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production   
    PL/SQL Release 11.2.0.2.0 - Production                                         
    CORE 11.2.0.2.0 Production                                                     
    TNS for Linux: Version 11.2.0.2.0 - Production                                 
    NLSRTL Version 11.2.0.2.0 - Production                                         
    SQL>
    SQL> set serveroutput on;
    SQL>
    SQL> DECLARE
      2     CURSOR c1
      3     IS
      4        WITH dmn
      5             AS (SELECT 1 col1, 'TEST' col2, NULL col3 FROM DUAL
      6             UNION ALL
      7                 SELECT 2 col1, 'TESTING' col2, 'COL3' col3 FROM DUAL
      8              UNION ALL
      9                 SELECT 3 col1, 'TESTING123' col2, 'COL3' col3 FROM DUAL
    10                )
    11        SELECT *
    12          FROM dmn;
    13 
    14     v_col1    VARCHAR2 (10);
    15     v_col2    VARCHAR2 (10);
    16     v_col3    VARCHAR2 (10);
    17     v_count   NUMBER;
    18  BEGIN
    19     OPEN c1;
    20 
    21     LOOP
    22        FETCH c1
    23        INTO v_col1, v_col2, v_col3;
    24        EXIT WHEN c1%NOTFOUND;
    25 
    26           WITH txn
    27             AS (SELECT 1 col1, 'TEST' col2, NULL col3 FROM DUAL
    28                 UNION ALL
    29                 SELECT 2 col1, 'TESTING' col2, 'COL3' col3 FROM DUAL
    30                )
    31        SELECT COUNT (*)
    32          INTO v_count
    33          FROM txn
    34         WHERE  col1 = v_col1
    35               AND col2 = v_col2
    36               AND nvl(col3,'##') = nvl(v_col3, '##');
    37 
    38           DBMS_OUTPUT.put_line ('V_count = ' || v_count);
    39        IF v_count = 0
    40        THEN
    41           DBMS_OUTPUT.put_line ('Insert is processed for ' || v_col1);
    42        ELSE
    43           DBMS_OUTPUT.put_line ('Insert is Ignored for ' || v_col1);
    44        END IF;
    45        v_count := 0;
    46     END LOOP;
    47  END;
    48  /
    V_count = 1                                                                    
    Insert is Ignored for 1                                                        
    V_count = 1                                                                    
    Insert is Ignored for 2                                                        
    V_count = 0                                                                    
    Insert is processed for 3                                                      
    PL/SQL procedure successfully completed.
    Thanks,
    GPU

  • Pl/sql procedure with shell script

    Hi Guys,
    I will be updating some of the columns in the database thru SQL UPDATE stament. I want to make this process automatic. I.e instead of running manually this uodate process, i want to write a unix script which run on cron job. In the update stament I have to compare date like e_create_date > to_date (........, 'yymmdd') and date should be 2 days previous then to date and I would ike to create the spool file which I would like to send through mail.the script will run automatically.
    I am confused how to write shell script & sql procedure and how to call it inside the shell script. How can this be done.
    Help Appreciated.
    Thanks
    sonu

    save the Store procedure as a create_SP.sql in OS
    save another testrun.sql
    as follows
    begin
    sp_test('&p_test');
    end;
    If you are on a Unix or Solaris OS then
    open a Shell Script as follows :
    and name as test.sh or test.ksh
    var='SYSTEM'
    export var
    sqlplus username/password
    @create_SP.sql
    -- this created a store procedure on the database
    @testrun.sql $var
    This will execute the SP with parameter from OS Variable.

  • FND_REQUEST PL/SQL procedure with parameters

    Hi guys
    I have created a concurrent program, using PL/SQL procedure which has 2 in parameters. I am trying to call the concurrent program using
    v_req_id :=FND_REQUEST.SUBMIT_REQUEST('INV','OMS_POP_INVVALUES_P',
    NULL,SYSDATE,FALSE,l_on_date, l_org_id,
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
    COMMIT;
    However, the concurrent program always failing with
    **Starts**26-AUG-2013 14:02:31 ORACLE error 6550 in FDPSTP Cause: FDPSTP failed due to ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'OMS_POP_INVVALUES_P' ORA-06550: line 1, column 7: PL/SQL: Statement ignored
    and I doubt it is because the database procedure call is not proper.
    I have set four parameters with the concurrent program, as they were with the procedure itself, which are
    p_on_date IN DATE, p_org_id IN NUMBER, errbuff   OUT VARCHAR2,retcode   OUT VARCHAR2
    Please help
    regards,
    raj

    Okay I fixed the problem by
    1. Changing the order of parameters with Procedure like following
    CREATE OR REPLACE PROCEDURE OMS_POP_INVVALUES_P (
    errbuff   OUT VARCHAR2,retcode   OUT NUMBER, p_on_date IN DATE, p_org_id IN NUMBER)
    IS
    and then changing the concurrent program call like following
    l_req_id :=
          fnd_request.submit_request('INV','OMS_POP_INVVALUES_P',
                                                                        NULL,SYSDATE,FALSE,l_in_date, l_org_id,CHR(0));
       :SYSTEM.Message_Level := '25';
       COMMIT;
    after removing all the parameters from the program parameter list. No need to pass any value for errbuff and retcode, just pass other parameters and end the parameter list with CHR(0). Hope this is useful for somebody else out there.
    Regards,
    raj

  • PROCEDURE WITH CURSOR ERROR

    I wanted to have a cursor in my procedure having results from different tables and different databases. I successfully created the query and compiled it using the procedure builder. However, when i was about to create it as stored procedure in iSQLplus, it displayed a warning. It says "Procedure created wuth compilation error." The first error is "PLS-00341: declaration of cursor 'SUBJ_CUR' is incomplete or malformed"
    Here's a piece of my code:
    PROCEDURE assess(STUD_ID VARCHAR2, STUD_YEAR NUMBER, STUD_TYPE CHAR) IS
    CURSOR subj_cur IS
    SELECT e.student_id, s.subject_id, s.subj_code, s.subject_title, s.units, s.pay_units,
    d.department_name, s.tuition_fee_type, s.lab_fee_type, f.year, f.amount
    FROM regist.enrol e, regist.offering o, regist.subject s,
    fee_details f, regist.student st, regist.department d
    WHERE (e.student_id = STUD_ID) AND (e.offering_id = o.offering_id) AND
    (o.subject_id = s.subject_id) AND (f.fee_no = s.tuition_fee_type) AND
    (st.student_id=e.student_id) AND ((f.year = STUD_YEAR) OR (f.year=0)) AND
    (s.department_id = d.department_id);
    regist and system are databases.
    Can anyone tell me where did I go wrong?
    I resorted though in creating views, however I still received an error. It says, "Insufficient privileges"
    Help me please..... I really need it badly..

    First of all, I've no experience with iSQLplus. I'm just wondering in which database the table fee_details is: system or regist? You didn't prefix the table.

  • Loop excution Problem in PL/Sql Procedure

    in the Below code the Loop is executing for more than 1 time .....query gets only one record ... if i run the Procedure with execution script the log output show below
    here i want to execute the procedure if i give multiple p_order_line_ids ...but if i give 1 order_line_id the loop is executed more than one time . i want to execute it only once ...anyone please help in this
    IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
        fnd_log.STRING (fnd_log.level_procedure, 'CSD.PLSQL.XXTNT_CSD_CREATEORDER.submit_Receive_Item.BEGIN', 'Enter - submit_Receive_Item');
      END IF;
      dbms_output.put_line('before  line query loop..');
      sqlStr := 'SELECT  d.repair_line_id Repair_line_id,'
                 || 'd.order_line_id Ship_line_id,d.order_header_id Order_header_id,'
                 || 'a.primary_vendor primary_vendor,a.serial_number serial_number,'
                 || 'a.contract_line_id contract_line_id, a.inventory_item_id inventory_item_id,'
                 || 'a.unit_of_measure unit_of_measure,a.repair_quantity repair_quantity,'
                 || 'a.cust_po_number cust_po_number,a.repair_org_id repair_org_id,b.incident_id incident_id'
                 || ' FROM xxtnt_csd_inbound_ord_lines_vl A,'
                 || ' CS_INCIDENTS_ALL B,csd_product_txns_v D, csd_repairs cr'
                 || ' WHERE A.ORDER_LINE_ID IN (' ||p_order_line_ids ||')'
                 || ' AND A.INCIDENT_NUMBER   = B.INCIDENT_NUMBER(+)'
                 || ' AND A.REPAIR_LINE_ID is not null'
                 || ' AND A.REPAIR_LINE_ID=D.REPAIR_LINE_ID(+)'
                 || ' AND d.repair_line_id=cr.repair_line_id(+)'
                 || ' AND d.action_type=''RMA'''
                 || ' AND d.interface_to_om_flag=''Y''';
        dbms_output.put_line(sqlStr);
        l_line_count := 0;
        Open c_Get_Line_data for sqlStr;
        LOOP
         IF(C_GET_LINE_DATA%NOTFOUND) THEN
                EXIT;
          END IF;
          FETCH C_GET_LINE_DATA INTO
           l_AUTORCV_TBL(1).REPAIR_LINE_ID,
           l_AUTORCV_TBL(1).ORDER_LINE_ID,
           l_AUTORCV_TBL(1).ORDER_HEADER_ID,
           l_primary_vendor,
           l_serial_number,
           l_contract_line_id,      
           l_inventory_item_id,     
           l_unit_of_measure,       
           l_repair_quantity,       
           l_cust_po_number,        
           l_repair_org_id,
           l_incident_id1;          
        XXXXXX.receive ( p_autorcv_tbl => l_AUTORCV_TBL,
                                                          x_return_status => x_return_status,
                                                          x_msg_count => x_msg_count,
                                                          x_msg_data => x_msg_data );
         IF(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
              update_status(p_repair_line_id             =>l_AUTORCV_TBL(1).REPAIR_LINE_ID,
                            p_vendor_id                =>l_primary_vendor,
                            p_serial_number            =>l_serial_number,
                            p_CONTRACT_LINE_ID         =>l_contract_line_id,
                            p_incident_id              =>l_incident_id1,
                            p_inventory_item_id        =>l_inventory_item_id,
                            p_unit_of_measure          =>l_unit_of_measure,
                            p_repair_quantity          =>l_repair_quantity,
                            p_customer_po_number       =>l_cust_po_number,
                            p_owning_organization_id   =>l_repair_org_id,
                            x_return_status            =>x_return_status
          IF(x_return_status != FND_API.G_RET_STS_SUCCESS) THEN
            RAISE FND_API.G_EXC_ERROR;
            END IF;
        ELSE
         RAISE FND_API.G_EXC_ERROR;
         END IF; 
          ---l_line_count :=l_line_count+1;
        END LOOP;

    Fetch before checking the NOTFOUND condition in the loop.
        LOOP
         IF(C_GET_LINE_DATA%NOTFOUND) THEN
                EXIT;
          END IF;
          FETCH C_GET_LINE_DATA INTO
           l_AUTORCV_TBL(1).REPAIR_LINE_ID,
           l_AUTORCV_TBL(1).ORDER_LINE_ID,
           l_AUTORCV_TBL(1).ORDER_HEADER_ID,
    ;      Should be
        LOOP
          FETCH C_GET_LINE_DATA INTO
           l_AUTORCV_TBL(1).REPAIR_LINE_ID,
           l_AUTORCV_TBL(1).ORDER_LINE_ID,
         IF(C_GET_LINE_DATA%NOTFOUND) THEN
                EXIT;
          END IF;
    vr,
    Sudhakar B.

Maybe you are looking for

  • Protected AAC Audio Files Help

    My own computer no longer has internet, where before it was connected to the main computer downstairs... I recently formatted my C: drive and reinstall Windows XP Home Edition and had to reinstalled iTunes and added all my music to iTunes again. Prob

  • How to deploy osb projects into managed server in weblogic

    i am new to osb i have a doubt i created a managed server in weblogic admin console, it was running fine ,but i need to know how to deploy my osb projects in that new manged server.As of now it is deployed in http://localhost:7001/sbconsole

  • Epub file format for the nook

    I recently put a book for sale on Barnes & Noble. I used InDesign to create the file, using the paragraph & character styles for formating. When I placed the file everything looked good in the preview including the bold subheads so I published. On th

  • Where to find the certificate number for Toshiba registration?

    Hi, I am new at this so forgive me if the question was already asked. I just bought a Satellite U200-170 and I want to register my self on the Toshiba site for the pickup and return services and the others services they are offering. The question now

  • Tuxedo 12 on linux vs system libraries - note to Oracle Tuxedo Dev Team

    Hello please consider renaming $TUXDIR/lib/libcrypto.so* library because it causes conflict with system libraries (debian wheezy for example) and disrupts other programs: $ ssh localhost ssh: /opt/bea/tuxedo12.1.1.0/lib/libcrypto.so.1.0.0: no version