"multiple cursor in a procedure" is possible?

Hi.. everyone.
Is it possible , "multiple cursor in one procedure"?
For example,
create or replace procedure xxx
is
vAAA varchar2(10);
vBBB varchar2(10);
cursor cur_1 is select .............................;
cursor cur_2 is select .............................;
begin
-- the first cursor
open cur_1;
loop
end loop;
close cur_1;
-- the second cursor
open cur_2;
loop
end loop;
close cur_2;
end;
If it is not possible, what is the way to use
multiple cursor(more than 2) in ONE procedure?
Thanks in advance.
Have a nice day.
Ho.

no problem
SQL> drop procedure xxx;
Procedure dropped.
SQL> CREATE OR REPLACE
  2  procedure xxx
  3  is
  4  vAAA varchar2(10);
  5  vBBB varchar2(10);
  6  cursor cur_1 is select employee_id from employees where rownum < 2;
  7  cursor cur_2 is select department_id from departments where rownum < 2;
  8
  9  begin
10  -----------------------------------------------
11  -- the first cursor
12  -----------------------------------------------
13  dbms_output.put_line('Cursor 1 Result');
14  open cur_1;
15  loop
16    fetch cur_1 into vAAA;
17    exit when cur_1%notfound;
18    dbms_output.put_line(vAAA);
19  end loop;
20  close cur_1;
21  -----------------------------------------------
22  -- the second cursor
23  -----------------------------------------------
24  dbms_output.put_line('Cursor 2 Result');
25  open cur_2;
26  loop
27    fetch cur_2 into vBBB;
28    exit when cur_2%notfound;
29    dbms_output.put_line(vBBB);
30  end loop;
31  close cur_2;
32  -----------------------------------------------
33  end;
34  /
Procedure created.
SQL> execute xxx;
Cursor 1 Result
100
Cursor 2 Result
10
PL/SQL procedure successfully completed.

Similar Messages

  • Return multiple cursors from one procedure

    Hi,
    I have a stored procedure that is suposed to return multiple records. I know that for each table that I return I have to add a param to the stored procedure, param with ref cursor type.
    I do not know exactly how many tables I have to return, it depends on data from some tables.
    Is it possible to return an unknown number of tables? like an array or something ...
    Please help

    In order to keep it transparent to the developer, I have to translate exactly the stored procedures from SQL Server to Oracle.Well "exactly" is not something that you are going to achieve. You're talking about two disperate languages. That's like saying you want to translate French to English, but it must stay French.
    You obviously want to mimick the existing functionality, but in some cases you're just going to have to bite the bullet and accept that you won't be able to do it totally transparently. In this case, the developers are going to have to make some changes at their end of things too.
    To translate the procedures from T-SQL to Oracle was
    the easiest and most convenient option to the
    developers, so they will not have to write different
    code for Oracle and SQL.But they will. Anyone who evaluated the project and determined that the developers wouldn't need to do anything when moving from one platform to another should be sacked for incompetence.
    ;)

  • How to pass multiple records to stored procedure??

    Hi,
    Can a web application call stored procedure (could be JDBC call)with resultset as it's input parameter? I'm sure there has to be some way to deal with this and I will appreciate your feedback. The web page has multiple records in tabular format and submit should save each record. Is it possible to pass all the records at once through resultset instead of calling stored procedure for each one?
    I'm thinking to use cursor variable as a input parameter of a stored procedure. But I'm not sure whether stored procedure can open/fetch this cursor variable into record structure. Here's the sample example of cursor variable definition.
    TYPE EmpRecTyp IS RECORD (
    emp_id NUMBER(4),
    emp_name VARCHAR2(10),
    job_title VARCHAR2(9),
    dept_name VARCHAR2(14),
    dept_loc VARCHAR2(13));
    TYPE EmpCurTyp IS REF CURSOR RETURN EmpRecTyp;
    PROCEDURE save_staff (emp_cv IN EmpCurTyp);
    Thanks for your help.
    Hemal

    You can't pass in a result set, but you can make each parameter a PL/SQL table.
    Since you also can't pass in a PL/SQL table of records, I typically create a parameter for each "field", with each parameter containing one or more elements. You can then use bulk binding to process the tables in one statement.

  • Effect of Multiple cursors in Function Module Extractors

    Hi,
    I am trying to use multiple cursors in an FM extractor, like this:
    OPEN CURSOR WITH HOLD c1 FOR <select query 1>.
    OPEN CURSOR WITH HOLD c2 FOR <select query 2>.
    FETCH NEXT CURSOR c1
                   INTO CORRESPONDING FIELDS
                   OF TABLE i_equi.
    FETCH NEXT CURSOR c2
                   APPENDING CORRESPONDING FIELDS
                   OF TABLE i_equi.
    " Further processing of equipments
    " obtained in i_equi
    I am also checking SY-SUBRC, after each Fetch statement. If both cursors happen to be empty, the extractor exits by raising no_more_data, like other extractors.
    It is possible to do so, since I just tried it. The question is, are there any disadvantages of this kind of approach in terms of memory or speed?
    Edited by: Suhas Karnik on Sep 29, 2008 12:06 PM

    hI kiran,
    The simple way is to create a data element & domain with value range where u provide set of fixed values or provide a check table to it.
    Use that data element in a table <ztable>.
    Code:
    Parameters:
          p_burks like <ztable>-dataelement.
    Call Function <function_name>
    exporting
    p_burks = p_burks,

  • Same EMP NUM in multiple cursors

    My plsql program is designed in such way that there are multiple cursors & each cursor needs input as EMPLOYEE NUMBER.
    This EMPLOYEE NUMBER should be same across all the cursors.
    Code is as below.
    Any kind of help here is appreciated. Thank you in advance.
    -- AGTSP
    SET SERVEROUTPUT ON
    alter session set nls_date_format='YYYY-MM-DD';
    DECLARE
        MY_FILE_DIR varchar2(40) := '/usr/tmp2';
        l_output        utl_file.file_type;
        v_file_handle varchar2(30) default 'Legacy_Job_Data.csv';
        buf varchar2(10230);
        v_ps_id varchar2(10);
        v_job_descr varchar2(40);
      v_belonging_name VARCHAR2(100);
      v_sg VARCHAR2(4);
      v_sg_jc VARCHAR2(6);
      v_EFFECTIVE_START_DATE DATE;
      SG VARCHAR2(10);
      v_count number;
    -- CJL DATA COLLECTION STARTS
    -- CURSOR STARTS
        CURSOR C_MAIN IS        
      select
                        EMP.EMPLOYEE_NUMBER AS EMPLOYEE_NUMBER
      , JOB.BELONGING_NAME
      , JOB.CHANGE_REASON_NAME
      , JOB.EFFECTIVE_START_DATE
      , JOB.EFFECTIVE_END_DATE
                    from
                        apps.zshr_employee_v EMP
                        , apps.ZSHR_ASSIGNMENT_V JOB
                    where
                        EMP.EMPLOYEE_NUMBER = JOB.EMPLOYEE_NUMBER
                    and TO_CHAR( EMP.EFFECTIVE_END_DATE , 'YYYY-MM-DD')='4712-12-31'                and JOB.QUALIFICATION_CODE <>'0151'
      ORDER BY EFFECTIVE_START_DATE DESC
    CURSOR C_SCM IS        
      SELECT
                        EMP.EMPLOYEE_NUMBER AS EMPLOYEE_NUMBER
      , JOB.BELONGING_NAME
      , JOB.CHANGE_REASON_NAME
      , JOB.EFFECTIVE_START_DATE
      , JOB.EFFECTIVE_END_DATE
                    from
                        apps.zshr_employee_v EMP
                        , apps.ZSHR_ASSIGNMENT_V JOB
                    where
                        EMP.EMPLOYEE_NUMBER = JOB.EMPLOYEE_NUMBER
                   and TO_CHAR( EMP.EFFECTIVE_END_DATE , 'YYYY-MM-DD') ='4712-12-31' and TO_CHAR( JOB.EFFECTIVE_END_DATE , 'YYYY-MM-DD') <'2008-08-01'
      and TO_CHAR( JOB.EFFECTIVE_START_DATE , 'YYYY-MM-DD') >= '1987-07-01'
      and JOB.QUALIFICATION_CODE <>'0151'
      and rownum=1
      ORDER BY EFFECTIVE_START_DATE ASC
    CURSOR C_CM IS        
      SELECT
                        EMP.EMPLOYEE_NUMBER AS EMPLOYEE_NUMBER
      , JOB.BELONGING_NAME
      , JOB.CHANGE_REASON_NAME
      , JOB.EFFECTIVE_START_DATE
      , JOB.EFFECTIVE_END_DATE
            from
                        apps.zshr_employee_v EMP
                        , apps.ZSHR_ASSIGNMENT_V JOB
                    where
                        EMP.EMPLOYEE_NUMBER = JOB.EMPLOYEE_NUMBER
                   and TO_CHAR( EMP.EFFECTIVE_END_DATE , 'YYYY-MM-DD') ='4712-12-31' and TO_CHAR( JOB.EFFECTIVE_START_DATE , 'YYYY-MM-DD') < '1987-07-01'
      and rownum =1
      ORDER BY EFFECTIVE_START_DATE ASC
    -- MAIN BODY BEGINS
    BEGIN
    -- FILE INITIALIZATION
        l_output := utl_file.fopen(MY_FILE_DIR,v_file_handle, 'w', 32767);
    -- WRITING THE FILE HEADER STARTS
        buf := 'EMPLID'
                    || ',EMPL_RCD'
                    || ',EFFDT'
                    || ',EFFSEQ'
                    || ',CX_EE_ID_NBR'
                    || ',CX_SECT_NM'
                    || ',LOCATION'
                    || ',CX_WRK_LOC_DESCR'
                    || ',JOBCODE'
                    || ',JOB_DESCR'
                    || ',GRADE'
                    || ',COMPRATE '
                    || ',CURRENCY_CODE'
                    || ',COMP_FREQUENCY'
        utl_file.put_line(l_output,buf);
    FOR C_EMP_rec in C_MAIN LOOP
    -- CJL LEGACY JOB DATA COLLECTION
    --PS ID EXTRACTION STARTS
      BEGIN
      select PS_ID INTO v_ps_id from apps.TB03569A where
            EBS_ID=C_EMP_rec.EMPLOYEE_NUMBER;
      EXCEPTION
      WHEN no_data_found THEN
      v_ps_id := 'NO DATA';
      END;
    --PS ID EXTRACTION END
      IF  C_EMP_rec.EFFECTIVE_START_DATE >= '2008/8/1' THEN
        buf := v_ps_id                               /* EMPLID */
               || ',' || 0                             /* EMPL_RCD */
               || ',' || C_EMP_rec.EFFECTIVE_START_DATE         /* EFFDT*/
               || ',' || 0                             /* EFFSEQ*/
               || ',' || C_EMP_rec.EMPLOYEE_NUMBER             /* CX_EE_ID_NBR */
                 || ',' || C_EMP_rec.BELONGING_NAME     /* CX_SECT_NM */
                 || ',' || ''                 /* LOCATION */
               || ',' || 'CX_WRK_LOC_DESCR'               /* CX_WRK_LOC_DESCR */
                 || ',' || C_EMP_rec.SG_JOB_CODE /* JOBCODE */
                 || ',' || v_job_descr               /* JOB_DESCR */
                 || ',' || C_EMP_rec.SG         /* GRADE */
               || ',' || ''       /* COMPRATE */
                 || ',' || 'JPY'               /* CURRENCY CODE */
                 || ',' || '' /* COMP FREQUENCY */
                 || ',' || C_EMP_rec.EMP_SG_T_O_FLG           /* SG T Oth. Flag */
      utl_file.put_line(l_output,buf);
      END IF;
    END LOOP;
    FOR C_SCM_rec in C_SCM LOOP
    --PS ID EXTRACTION STARTS
      BEGIN
      select PS_ID INTO v_ps_id from apps.TB03569A where
            EBS_ID=C_SCM_rec.EMPLOYEE_NUMBER;
      EXCEPTION
      WHEN no_data_found THEN
      v_ps_id := 'NO DATA';
      END;
    --PS ID EXTRACTION END
    buf := v_ps_id                               /* EMPLID */
               || ',' || 0                             /* EMPL_RCD */
               || ',' || C_SCM_rec.EFFECTIVE_START_DATE         /* EFFDT*/
               || ',' || 0                             /* EFFSEQ*/
               || ',' || C_SCM_rec.EMPLOYEE_NUMBER             /* CX_EE_ID_NBR */
                 || ',' || C_SCM_rec.BELONGING_NAME     /* CX_SECT_NM */
                 || ',' || ''                 /* LOCATION */
               || ',' || 'CX_WRK_LOC_DESCR'               /* CX_WRK_LOC_DESCR */
                 || ',' || C_SCM_rec.SG_JOB_CODE /* JOBCODE */
                 || ',' || 'v_job_descr'               /* JOB_DESCR */
                 || ',' || C_SCM_rec.SG         /* GRADE */
               || ',' || ''       /* COMPRATE */
                 || ',' || 'JPY'               /* CURRENCY CODE */
                 || ',' || '' /* COMP FREQUENCY */
                 || ',' || C_SCM_rec.EMP_SG_T_O_FLG           /* SG T Oth. Flag */
      utl_file.put_line(l_output,buf);
    -- SCM DATA COLLECTION STARTS
    END LOOP;
    -- SCM DATA COLLECTION ENDS
    FOR C_CM_rec in C_CM LOOP
    --PS ID EXTRACTION STARTS
      BEGIN
      select PS_ID INTO v_ps_id from apps.TB03569A where
            EBS_ID=C_CM_rec.EMPLOYEE_NUMBER;
      EXCEPTION
      WHEN no_data_found THEN
      v_ps_id := 'NO DATA';
      END;
    --PS ID EXTRACTION END
      BEGIN
      select count(*) INTO v_count from
      SELECT 
      distinct
      EMP.EMPLOYEE_NUMBER
      , JOB.ASSIGNMENT_NUMBER
      , JOB.ASSIGNMENT_ID
      from
      apps.zshr_employee_v EMP
      , apps.ZSHR_ASSIGNMENT_V JOB
      where
      EMP.EMPLOYEE_NUMBER=JOB.EMPLOYEE_NUMBER
      and EMP.EMPLOYEE_NUMBER=C_CM_rec.EMPLOYEE_NUMBER
      EXCEPTION
      WHEN no_data_found THEN
      v_count := 0;
      END;
      IF v_count > 1 THEN
      v_job_descr := 'MHI';
      ELSE
      v_job_descr := 'CM';
      END IF;
      buf := v_ps_id                           /* EMPLID */
               || ',' || 0                             /* EMPL_RCD */
               || ',' || C_CM_rec.EFFECTIVE_START_DATE         /* EFFDT*/
               || ',' || 0                             /* EFFSEQ*/
               || ',' || C_CM_rec.EMPLOYEE_NUMBER             /* CX_EE_ID_NBR */
                 || ',' || C_CM_rec.BELONGING_NAME     /* CX_SECT_NM */
                 || ',' || ''                 /* LOCATION */
               || ',' || 'CX_WRK_LOC_DESCR'               /* CX_WRK_LOC_DESCR */
                 || ',' || C_CM_rec.SG_JOB_CODE /* JOBCODE */
                 || ',' || v_job_descr               /* JOB_DESCR */
                 || ',' || C_CM_rec.SG         /* GRADE */
               || ',' || ''       /* COMPRATE */
                 || ',' || 'JPY'               /* CURRENCY CODE */
                 || ',' || '' /* COMP FREQUENCY */
                 || ',' || C_CM_rec.EMP_SG_T_O_FLG           /* SG T Oth. Flag */
      utl_file.put_line(l_output,buf);
    -- SCM DATA COLLECTION STARTS
    END LOOP;
        utl_file.fclose(l_output);
    END;

    Well, I'm not sure what you're issue is as you haven't told us.
    Typically cursors within cursors or multiple cursors are a bad idea, and you should look to try and combine SQL statements into one statement where possible.
    I do however, notice that you've specifying an operating system path for your directory (/usr/tmp2).  You should not use o/s paths with Oracle, you should use Oracle directory objects e.g.
    The UTL_FILE_DIR parameter has been deprecated by oracle in favour of direcory objects because of it's security problems.
    The correct thing to do is to create a directory object e.g.:
    CREATE OR REPLACE DIRECTORY mydir AS 'c:\myfiles';
    Note: This does not create the directory on the file system. You have to do that yourself and ensure that oracle has permission to read/write to that file system directory.
    Then, grant permission to the users who require access e.g....
    GRANT READ,WRITE ON DIRECTORY mydir TO myuser;
    Then use that directory object inside your FOPEN statement e.g.
    fh := UTL_FILE.FOPEN('MYDIR', 'myfile.txt', 'r');
    Note: You MUST specify the directory object name in quotes and in UPPER case for this to work as it is a string that is referring to a database object name which will have been stored in uppercase by default.

  • Multiple Cursors in an OracleResultSet

    Is it possible to iterate over multiple cursors in an OracleResultSet at the same time, or do you have to iterate over a result set (get all the data), then iterate over another resultset (get all the data). See example code 1 and example code 2 below:
    Example Code 1
    =============
    Map output = new HashMap();
              try {
                   // make connection
                   // send JDBC call
                   ResultSet cursor1 = null;
                   while (cursor1.next()) {
                        CartBean chart = new CartBean();
                        cart.setCartName(cursor1.getString("Name"));
                        cart.setCartType(cursor1.getString("Type"));
                        output.put(cart.getCartName(), cart);
                   ResultSet cursor2 = null;
                   while (cursor2.next()) {
                        CartBean chart = (CartBean) output.get(cursor2
                                  .getString("CartName"));
                        Map series = cart.getSeriesData();
                        series.put(cursor2.getString("Label"), new HashMap());
    Example Code 2
    =============
    Map output = new HashMap();
              try {
                   // make connection
                   // send JDBC call
                   ResultSet cursor1 = null;
                   while (cursor1.next()) {
                        CartBean chart = new CartBean();
                        cart.setCartName(cursor1.getString("Name"));
                        cart.setCartType(cursor1.getString("Type"));
                        output.put(cart.getCartName(), cart);
                   ResultSet cursor2 = null;
                   while (cursor2.next()) {
                        Map series = cart.getSeriesData();
                        series.put(cursor2.getString("Label"), new HashMap());
    }

    Hi Nathan,
    I don't full understand your requirements.  It would help if you could give a bit more background information about what you want to achieve.  Assuming you want one row in temp_store_newta for each store, then the following should do it (untested).
    declare
      l_union sdo_geometry;
      l_remainder sdo_geometry;
    begin
      for r1 in (
      select rowid, store_id, client_id, geometry
      from tmcs.tmcs_all_stores_ta
      where client_id = 1
      and rownum < 4)
      loop
      dbms_output.put_line('The primary --> ' || r1.store_id);
      select sdo_aggr_union(sdoaggrtype(geometry, 0.005))
      into l_union
      from tmcs.tmcs_all_stores_ta
      where client_id = 1
      and sdo_anyinteract(geometry, r1.geometry) = 'TRUE'
      and rowid != r1.rowid;
      l_remainder := sdo_geom.sdo_difference(r1.geometry, l_union, 0.005);
      if l_remainder is not null then
       dbms_output.put_line('Inserting the remainder for ' || r1.store_id);
       insert into tmcs.temp_store_newta values (r1.store_id, r1.store_number, r1.client_id, l_remainder);
      else
       dbms_output.put_line('Nothing left after punching out all the other geometries');
      end if;
    end loop r1;
    commit;
    end;
    John

  • Returning SQL cursor from Stored Procedure

    Hi,
    I have a query regarding returning sql cursor from stored procedure to java in oracle 11g.
    I want to query some data ex: my query returns A, B, C. Also, now I want to query some other data ex: D, E, F. Now I want to return this data as an sql cursor as a single row . Example: A,B,C,D,E,F. Is it possible to return/create a cursor in stored procedure?
    assume both query returns equal number of rows.. however both are not related to each other..

    RP wrote:
    Hi,
    I have a query regarding returning sql cursor from stored procedure to java in oracle 11g.
    I want to query some data ex: my query returns A, B, C. Also, now I want to query some other data ex: D, E, F. Now I want to return this data as an sql cursor as a single row . Example: A,B,C,D,E,F. Is it possible to return/create a cursor in stored procedure?
    assume both query returns equal number of rows.. however both are not related to each other..It sounds like what you need is a ref cursor.
    First thing to remember though is that cursors do not hold any data (see: {thread:id=886365})
    In it's simplest form you would be creating a procedure along these lines...
    SQL> create or replace procedure get_data(p_sql in varchar2, p_rc out sys_refcursor) is
      2  begin
      3    open p_rc for p_sql;
      4  end;
      5  /
    Procedure created.
    SQL> var rc refcursor;
    SQL> exec get_data('select empno, ename, deptno from emp', :rc);
    PL/SQL procedure successfully completed.
    SQL> print rc;
         EMPNO ENAME          DEPTNO
          7369 SMITH              20
          7499 ALLEN              30
          7521 WARD               30
          7566 JONES              20
          7654 MARTIN             30
          7698 BLAKE              30
          7782 CLARK              10
          7788 SCOTT              20
          7839 KING               10
          7844 TURNER             30
          7876 ADAMS              20
          7900 JAMES              30
          7902 FORD               20
          7934 MILLER             10
    14 rows selected.
    SQL> exec get_data('select deptno, dname from dept', :rc);
    PL/SQL procedure successfully completed.
    SQL> print rc
        DEPTNO DNAME
            10 ACCOUNTING
            20 RESEARCH
            30 SALES
            40 OPERATIONS
            50 IT SUPPORTWhich takes an SQL statement (as you said that both your queries were unrelated), and returns a ref cursor, and then your Java code would fetch the data using that cursor.
    Now, as for getting your rows to columns and combining two queries that do that... something along these lines...
    SQL> select * from x;
    C
    A
    B
    C
    SQL> select * from y;
    C
    D
    E
    F
    SQL> ed
    Wrote file afiedt.buf
      1  select x.col1, x.col2, x.col3
      2        ,y.col1 as col4
      3        ,y.col2 as col5
      4        ,y.col3 as col6
      5  from (
      6        select max(decode(rn,1,col1)) as col1
      7              ,max(decode(rn,2,col1)) as col2
      8              ,max(decode(rn,3,col1)) as col3
      9        from (select col1, rownum rn from (select * from x order by col1))
    10       ) x
    11  cross join
    12       (
    13        select max(decode(rn,1,col1)) as col1
    14              ,max(decode(rn,2,col1)) as col2
    15              ,max(decode(rn,3,col1)) as col3
    16        from (select col1, rownum rn from (select * from y order by col1))
    17*      ) y
    SQL> /
    C C C C C C
    A B C D E F... will do what you ask. For further information about turning rows to columns read the FAQ: {message:id=9360005}

  • How to add (multiple) cursors programmatically in an XY graph?

     how to add (multiple) cursors programmatically in an XY graph?
    I am building an XY graph. then I would like to add cursors at certain locations (positioned on x axis) I determine through a program.
    How can I add cursors programatically?
    Thank you.

    Initialize a cluster array (CrsrList type) with as many cursors as you think you would ever need.   Setup your cursors dynamically, then delete the unused cursors (array elements) and then update your CursorList property.
    Message Edited by vt92 on 03-20-2009 04:04 PM
    "There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
    Attachments:
    cursors.PNG ‏5 KB

  • Dynamic Cursor in a procedure

    Hi,
    I am using 10g and wanted to check if we can use a dynamic cursor in a procedure.
    Following is my code and wanted to see if that can work with every query passed as a parameter.
    example ,
    exec test1 ('select col1, col2, col3 from table1','Two columns Sql')
    exec test1 ('select col1 from table2','one columns Sql')
    exec test1 ('select col1, col2, col3, col4, col5 from table3','Five columns Sql')
    CREATE OR REPLACE procedure test1 (p_sql IN VARCHAR2, p_subject IN VARCHAR2
    is
      v_cu_string       VARCHAR2(2000);
      v_string          VARCHAR2(2000);
      v_sql             VARCHAR2(4000);
      v_head            VARCHAR2(4000);
      v_head_sql        VARCHAR2(4000);
      v_str_sql         VARCHAR2(4000);
          TYPE cv_typ IS REF CURSOR;
          cv cv_typ;
    begin
      v_sql := p_sql;
        OPEN cv FOR v_sql;
           LOOP
             FETCH cv INTO v_cu_string;
             EXIT WHEN cv%NOTFOUND;
            ------ Processing steps
          END LOOP;
          CLOSE cv;
    END;Thanks

    user527060 wrote:
    Following is my code and wanted to see if that can work with every query passed as a parameter.
    Just curious as to why this is an improvement of
    exec test1 ('select col1, col2, col3 from table1','Two columns Sql')
    select col1, col2, col3 from table1And
    exec test1 ('select col1 from table2','one columns Sql')
    select col1 from table2And
    exec test1 ('select col1, col2, col3, col4, col5 from table3','Five columns Sql')
    select col1, col2, col3, col4, col5 from table3It needs more code from you to build, more code for anyone to enter to execute, limits selects to only one table I would guess also comes with less documentation than SQL.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/toc.htm

  • Cursor in stored procedure fails

    Hi,
    In our application we have a stored procedure which is called with in parameters to generate data into some table. This procedure is being called from another procedure.
    This procedure has been used to generate data into the table without any problem since oracle 9i. Last year we have upgraded to oracle 11g after that this procedure is failing intermittently to generate data. When this procedure is executed 50 times it fails atleast once to generate data. If we rerun the procedure for the failed case it generates the data without any change to program code nor any change in underlying data. It doesn't fail if we rerun. Therefore we are unable to simulate the problem.
    Procedure has got a very simple code.
    proc1 (p1 date,p2 date) is
    begin
    for c1_rec in c1 (select col1,col2
    from x,y where x.......)
    loop
    end loop;
    end;
    First we thought for some reason this procedure was not executed at all. But it is not the case. Actually it calls the procedure but the cursor inside the procedure doesn't fetch any records. Also it doesn't report any oracle error.
    Appreciate if any one can help me in this.
    Thanks & Regards,
    Raja

    vaidyanathanraja wrote:
    4. If there is a logical error, the same procedure should not generate data when it is rerun. Behaviour should be the same at all times.Incorrect. Something like NLS settings for example can make the same code, behave differently. E.g. a date string is passed and implicitly converted to a date. And this will work for most dates from different session using different NLS settings (e.g. yyyy/mm/dd versus yyyy/dd/mm). And these sessions will provide different results using the same parameters calling the same application code.
    There are a number of such run-time factors that influences code.
    5. Failed means it didn't generate the expected output. Which means that there is a problem with that SQL being executed the way it is, with the parameters used. You need to isolate the problem further.
    6. Parameter values are right.Have you proved that by using a test case that runs the very same SQL via a test proc, using the same parameter, via a job? Ran that test case interactively via sqlplus?
    You need to pop the hood and isolate the problem.
    7. I came across one blog saying different behaviour for REF CURSOR between oracle 10g and 11g and he says it is oracle bug. I don't know whether it is applicable for this case also.Bahumbug. There are many Oracle bugs. As there is in all software. However, you have not provided any evidence of a bug.
    Application code is behaving inconsistently. That is the symptom. Oracle system code is not relevant until you can prove that the inconsistency is not in the application code, but lower down the call stack.

  • Open Cursor in a procedure

    Hi to all,
    my problem is to open a cursor into a procedure.
    The code is the following:
    PROCEDURE p_selection_customer
    IS
         CURSOR cursor_customer IS
              SELECT
              c_u.id_customer
              FROM
              customer_unified_a c_u;
         BEGIN
              FOR record_customer IN cursor_customer LOOP
                   ROLLBACK;
              END LOOP;
    END p_selection_customer;
    The error is :
    Errore(55,3): PL/SQL: SQL Statement ignored
    Errore(58,3): PL/SQL: ORA-06552: PL/SQL: Compilation unit analysis terminated ORA-06553: PLS-320: the declaration of the type of this expression is incomplete or malformed
    This procedure is defined in the spec. Then I suppose that my problem is that I can't open a cursor into my schema. Do I verify this hypotesys in my schema? Do I have some queries? My schema don't have the dba and sys grants.
    Thank'you very match!

    Hi Alex,
    this is the complete script used to generate the table.
    Me too, I knew that the partition was transparent to the Cursor statement.
    Thank'you very match!
    CREATE TABLE "SSVILCID"."TW_E_CUSTOMER_UNIFIED_A"
       (     "ID_CUSTOMER_UNIFIED" VARCHAR2(27 BYTE) NOT NULL ENABLE,
         "START_VALIDITY_DATE" DATE NOT NULL ENABLE,
         "START_ASINC_DATE" DATE NOT NULL ENABLE,
         "END_ASINC_DATE" DATE,
         "CUSTOMER_STATUS" VARCHAR2(255 BYTE),
         "TERMINATION_DATE" DATE,
         "CUSTOMER_DOMAIN" VARCHAR2(255 BYTE),
         "CUSTOMER_CLUSTER" VARCHAR2(255 BYTE),
         "CUSTOMER_SENIORITY" DATE,
         "ACTIVATION_DATE" DATE,
         "ACQUISITION_DATE" DATE,
         "ACQUISITION_CHANNEL" VARCHAR2(255 BYTE),
         "SUB_ACQUISITION_CHANNEL" VARCHAR2(255 BYTE),
          CONSTRAINT "TW_E_CUSTOMER_UNIFIED_A_PK" PRIMARY KEY ("START_ASINC_DATE", "ID_CUSTOMER_UNIFIED", "START_VALIDITY_DATE")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "SYSTEM"  ENABLE
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
      PARTITION BY RANGE ("START_ASINC_DATE")
      SUBPARTITION BY LIST ("END_ASINC_DATE")
    (PARTITION "M200909"  VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
    ( SUBPARTITION "M200909_N"  VALUES (NULL)
       TABLESPACE "DATI",
      SUBPARTITION "M200909_NN"  VALUES (DEFAULT)
       TABLESPACE "DATI") ,
    PARTITION "M200910"  VALUES LESS THAN (TO_DATE(' 2009-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
    ( SUBPARTITION "M200910_N"  VALUES (NULL)
       TABLESPACE "DATI",
      SUBPARTITION "M200910_NN"  VALUES (DEFAULT)
       TABLESPACE "DATI") ,
    PARTITION "M200911"  VALUES LESS THAN (TO_DATE(' 2009-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
    ( SUBPARTITION "M200911_N"  VALUES (NULL)
       TABLESPACE "DATI",
      SUBPARTITION "M200911_NN"  VALUES (DEFAULT)
       TABLESPACE "DATI") ,
    PARTITION "M200912"  VALUES LESS THAN (TO_DATE(' 2010-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
    ( SUBPARTITION "M200912_N"  VALUES (NULL)
       TABLESPACE "DATI",
      SUBPARTITION "M200912_NN"  VALUES (DEFAULT)
       TABLESPACE "DATI") ,
    PARTITION "M201001"  VALUES LESS THAN (TO_DATE(' 2010-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
    ( SUBPARTITION "M201001_N"  VALUES (NULL)
       TABLESPACE "DATI",
      SUBPARTITION "M201001_NN"  VALUES (DEFAULT)
       TABLESPACE "DATI") ,
    PARTITION "M201002"  VALUES LESS THAN (TO_DATE(' 2010-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
    ( SUBPARTITION "M201002_N"  VALUES (NULL)
       TABLESPACE "DATI",
      SUBPARTITION "M201002_NN"  VALUES (DEFAULT)
       TABLESPACE "DATI") ,
    PARTITION "FUTURE"  VALUES LESS THAN (MAXVALUE)
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
    ( SUBPARTITION "M210001_N"  VALUES (NULL)
       TABLESPACE "DATI",
      SUBPARTITION "M210001_NN"  VALUES (DEFAULT)
       TABLESPACE "DATI") )  ENABLE ROW MOVEMENT ;

  • [Help] statement.executeQuery(query) opens MULTIPLE cursors

    Hey everyone,
    I'm having a real hard time finding anything about this on the net so I've turned here. When we call:
    resultSet = statement.executeQuery(query)
    from a servlet for some reason that one executeQuery opens anywhere from 9-12 cursors in our oracle DB. All the executeQuery documentation I could find just said it should open 1 cursor for that particular ResultSet. query is a fairly simple SQL statement, it searches multiple tables but that doesn't explain why it should open so many cursors.
    On a side note the resultSet and statement are global to the method and are closed in the finally block, no SQLExceptions are thrown further adding to my confusion.
    If anyone has seen something like this where executing 1 query opens multiple cursors please let me know any information you might have.
    Thanks in advance
    -Dave

    Hi Dave
    I had a similar problem using the Oracle 8i, but my query was a more complicated than yours and opened a lot of cursors.
    The answer is to close every ResultSet and the Statement:
    while (xxResult.next()){ ... }
    xxResult.close();
    xxResult.getStatement().close();
    This worked for me,
    Good luck,
    Daniel.

  • Error - Logon not possible; none of the active logon procedures is possible

    Dear Gurus,
    I'm trying to configure SSL with User mapping to SICF service: NWBC.
    -SSL configured with STRUST transaction and I see that it is working via Internet Explorer
    -SICF service NWBC was set to: "Required with Client Certificate (SSL)"
    -User mapping was set like described in this article: https://help.sap.com/saphelp_nwmobile71/helpdata/en/17/1514e9b7eb4f74b0b49327b8f2a662/frameset.htm
    But I get error:
    Logon not possible; none of the active logon procedures is possible
    Any idea ?
    Please advise,
    Dimitry Haritonov

    Hi,
    I would try to check logs first. In transaction SMICM you can set up level of logging for ICF services. So set it up to the highest possible level (this one actually dumps whole content of HTTP request, so maybe that's not necessary) and try logon again. You should get a reasonable info and you can try to figure out why it fails.
    Cheers

  • Can we define cursors from in procedure while using .procedure file?

    Hi Team,
    Can we define cursors from in procedure while using .procedure file?
    I have a catalog procedure in which am using cursors and it is working fine. But while trying to create the same procedure using .procedure , the validation is failing with "An error occurred while parsing your procedure".
    Request your suggestions.
    Regards,
    Krishna Tangudu

    Hi Krishna,
    I also tried to find the validation for procedure and failed. What was on my mind when I posted earlier was related to Window -> Properties -> SAP HANA -> Modeler -> Validation Rules but this is not the same for procedure.
    Also the validation error seems to not being raised by Studio but the server, so it's not a frontend validation anyway.
    Trying to replicate your error I create two procedures here and both worked fine with cursor.
    The behavior you found was the same I found, the .procedure goes to repository and _SYS_BIC after activation and .hdbprocedure goes to catalog only.
    As far as I understood as you are moving from catalog (manually) and it worked on catalog (.hdbprocedure), I could check the declaration of table types of header as it's the main difference.
    Despite this investigation of declaration, you can try create it on modeler direct and see what you found on .procedure created. This can speed up investigation.
    Regards, Fernando Da Rós
    BTW: I'm faced an very strange behavior that each caracter I type on .procedure or .hdbprocedure freezes studio by around 15 seconds ?!?!?!?! (studio rev73)

  • How to insert one table data into multiple tables by using procedure?

    How to insert one table data into multiple tables by using procedure?

    Below is the simple procedure. Try the below
    CREATE OR REPLACE PROCEDURE test_proc
    AS
    BEGIN
    INSERT ALL
      INTO emp_test1
      INTO emp_test2
      SELECT * FROM emp;
    END;
    If you want more examples you can refer below link
    multi-table inserts in oracle 9i
    Message was edited by: 000000

Maybe you are looking for

  • Itunes 10.2.1.1 windows 7 64-bit Player does not work

    Well, my itunes quit working yesterday, and I can't figure it out. I've had the 64-bit version on this computer for sometime, and now it opens just fine, everything seems to function just fine, but when I go to play a song it just sits @ 0:00, if you

  • Video Transition Error Help...

    Hi. The clip what i work is mont format, i have fixed in motion. I have rendel that back in final cut and now i whant to but middle in two clip addictive dissovelve effect but i get X in the video transition like this http://www.insertxox.com/finalcu

  • Why is the size of my pdf increasing after I add text fields?

    I have a simple pdf that by itself is 350kb. But when I add 4 text form fields it increases the size to 2.8mb. Why is this and what can I do to decrease the size but keep the fporm fields for users to type into? thanks

  • Table maintenance generator and Change pointers

    If a Ztable contains table maintenance generator, then the change pointers will not work?

  • Packets sent out on wrong interface

    We have a BM 3.9 SP1 server configured with two public interfaces which are Interface 1 XXX.XXX.138.178 mask 255.255.255.240 with a secondary IP address of XXX.XXX.138.179 and is has the default route of XXX.XXX.138.177. Interface 2 XXX.XXX.146.218 m