Dynamic cursor error:

Hi experts

Please help me with this error
In this code the terms cursor not add to the query
so when I execute the result it displays error
can you help me on this
SQL> CREATE OR REPLACE PROCEDURE test_dynamic_detailed_rpt (
  2     v_typ             IN       VARCHAR2,
  3     v_initiator   IN       VARCHAR2,
  4     p_rc                  OUT      sys_refcursor
  5  )
  6  IS
  7     v_sql   VARCHAR2(32767);
  8  BEGIN
  9     v_sql := 'SELECT  COUNT(*) FROM  txnlg tl WHERE ';
 10
 11      v_sql := v_sql||'tl.typ = ''1''';
 12
 13
 14           FOR j IN (SELECT tc.tgid, tc.tranid, tc.reqtype
 15                       FROM txnccde tc
 16                      WHERE tc.actstatus = 'Y'
 17                        AND tc.txndesc = v_typ)
 18           LOOP
 19              IF LENGTH (j.tgid) < 4
 20              THEN
 21                 v_sql := v_sql || ' OR ''UP''||J.tgid';
 22                 --'''|| v_typ|| ''')';
 23              ELSE
 24                 v_sql := v_sql || ' OR   J.tgid';
 25              END IF;
 26           END LOOP;
 27
 28     DBMS_OUTPUT.PUT_LINE(v_sql);
 29  END;
 30  /

Procedure created.

SQL>
SQL> set serveroutput on;
SQL>
SQL> Var  p_rc refcursor;
SQL>
SQL> BEGIN
  2  test_dynamic_detailed_rpt('ALL','C',:p_rc);
  3  END;
  4  /
SELECT  COUNT(*) FROM  txnlg tl WHERE tl.typ = '1'

PL/SQL procedure successfully completed.

SQL>
SQL> print p_rc;
ERROR:
ORA-24338: statement handle not executed


SP2-0625: Error printing variable "p_rc"
SQL>

If you think you need to use dynamic SQL statements to apply additional conditions (if you did not specify this) simply not so like this code you looks like it generates:

select count(*)
from tab1
where col1 = (1st value from tab2)
or col1 = (2nd value from tab2)
.
.
.
or col1 = (nth value from tab2)
/

while I would say that you are better off getting:

select count(*)
from tab1
, tab2
where (tab1.col1 = tab2.col1 and length tab2.col2 <4)
  or (tab1.col1 = 'xx'||tab2.col1 and length tab2.col2 >=4)
/

Because the second query is only long, not n (plus some) lines long. No matter if you write SQL static or dynamic: you must write a SQL query appropriate, concise and not a huge, sprawling. Then you will not have to worry about the limitation of the data type VARCHAR2 holding the full text of the query.

If, after writing a nice concise sql query and it is always > 32 k long, so you might want to look at using the VARCHAR2S and DBMS_SQL data type. TO_REFCURSOR

The example tables and data and the required results will make usefule much easier to give advice.

Ben

Tags: Database

Similar Questions

  • Dynamic cursor Type strong?

    I am currently using Oracle 11.2 G and I was wondering if you can declare a dynamic cursor as a strong Ref Cursor type or it may be declared as weak type ref cursor? Now, if she can only be declared as a weak type Ref Cursor, is it possible to avoid having to explicitly declare the type names and field being returned by the cursor? Sense, is any way to avoid having to do something like that...
    TYPE example_rec IS RECORD
    (
     col1 VARCHAR2,
     col2 NUMBER,
     col3 NUMBER,
     etc...
    )
    Instead, I was wondering if I could just set the fields and their types by defining them as a TABLE OF THE ref cursor?

    I wonder if this is possible is because I have a large number of fields returned in my cursor, and I was hoping on not having to type each person and its type. In addition, I think this would make maintenance easier.

    user652714 wrote:
    No, not quite. I ask if I can create a strong dynamic type Ref cusors. Here is a Pseudo code:

    DECLARE
    TYPE test_rec IS TABLE OF test_cur%ROWTYPE; -- i'm wondering if i can do something like this
    --'The code below is what I am TRYING TO AVOID'
    TYPE test_cur IS REF CURSOR;
    TYPE test_rec IS RECORD
    (
    col1 VARCHAR2,
    col2 NUMBER,
    col3 NUMBEr
    )
    

    Is not possible.

    Let's say you would set an TEST_REC as above. How would refer to the members of the structure of your code? This type could describe anything like projection of the cursor could be anything - a unique column, to a 100 columns. A combination of columns that can include data types of the LOB of tables nested SQL types defined by the user.

    So, how can you refer to these columns in the structure of table TEST_REC ? Guess?

    A new concept - all SQL statements are parsed, stored and executed as sliders. REF CURSOR, cursors implicit, explicit cursors and so on, are CLIENT interfaces to the created SQL cursor. Each of these interfaces to client cursor works in a specific way and provide a set of specific features.

    Next concept - to extract a SQL cursor, the client code NEEDS to know the structure of the projection of this cursor SQL. The code needs to know the number and types of data in the columns returned by the cursor.

    The customer may address the issue in two ways.

    Statically. In other words, at the time of coding, SQL projection, returned by this SQL cursor is known. The developer can thus use some thing like + % RowType % + to indicate to the compiler that record structure to define. The compiler parses the SQL cursor in the code, describes the projection of SQL and compiles this projection of SQL as the static structure in the code.

    + % RowType + in this regard is as a #define of C macro. He tells the PL/SQL compiler to describe the cursor SQL projection, then produced a PL/SQL, based on the record structure.

    Dynamically. This means at the time of coding, SQL, returned by this SQL cursor is unknown. In this case the compiler has no idea at compile time what structure will be returned by the cursor. Compiled source code may not define a static structure for this cursor SQL - the SQL cursor may return any kind of structure. The source code needs to use the same approach as what the compiler does when it comes to SQL static cursors.

    The source code needs to analyze the cursor, describe the SQL cursor and then pick dynamically by the cursor. Client cursor interface that supports this approach is DBMS_SQL. No ref Cursor.

    Keep in mind that these static and dynamic methods to describe how the code consumes the cursor - extraction of rows in the cursor.

    A static method (where the projection of SQL is known) however apply to the TWO instructions static SQL and dynamic SQL statements. You can use dynamic SQL statements in your code, but a rule which stipulates that, regardless of the SQL code is waiting for a specific static SQL projection of this SQL cursor.

    The dynamic method (where the projection of SQL is unknown) is 'real' dynamic SQL - as the projection of SQL and are all two dynamic SQL code.

    Examples of Basic code:

    // STATIC SQL CURSOR
    SQL> create or replace procedure FooProc is
      2          cursor  c is select object_id, object_name from user_objects;
      3          type    TBuffer is table of c%RowType;
      4          buffer  TBuffer;
      5  begin
      6          open c;
      7          loop
      8                  fetch c bulk collect into buffer limit 100;
      9                  DBMS_OUTPUT.put_line( buffer.Count||' row(s) fetched.' );
     10                  exit when c%NotFound;
     11          end loop;
     12          close c;
     13  end;
     14  /
    
    Procedure created.
    
    SQL>
    SQL> exec FooProc
    100 row(s) fetched.
    43 row(s) fetched.
    
    PL/SQL procedure successfully completed.
    
    // STATIC SQL PROJECTION, BUT DYNAMIC SQL CURSOR
    SQL> create or replace procedure FooProc( c in out sys_refcursor ) is
      2          E_CURSOR_ERROR  exception;
      3          pragma exception_init( E_CURSOR_ERROR, -00932 );
      4          type    TRecord is record(
      5                          name varchar2(30),
      6                          value varchar2(100)
      7                  );
      8          type    TBuffer is table of TRecord;
      9          buffer  TBuffer;
     10  begin
     11          loop
     12                  fetch c bulk collect into buffer limit 100;
     13                  DBMS_OUTPUT.put_line( buffer.Count||' row(s) fetched.' );
     14                  exit when c%NotFound;
     15          end loop;
     16          close c;
     17  exception when E_CURSOR_ERROR then
     18          close c;
     19          raise_application_error(
     20                  -20000,
     21                  'Cursor projection contains an invalid data structure.'
     22          );
     23  end;
     24  /
    
    Procedure created.
    
    SQL> var c refcursor
    SQL> exec open :c for select object_id, object_name from user_objects;
    
    PL/SQL procedure successfully completed.
    
    SQL> exec FooProc( :c );
    100 row(s) fetched.
    43 row(s) fetched.
    
    PL/SQL procedure successfully completed.
    
    SQL> exec open :c for select object_id, object_name, created from user_objects;
    
    PL/SQL procedure successfully completed.
    
    SQL> exec FooProc( :c );
    BEGIN FooProc( :c ); END;
    
    *
    ERROR at line 1:
    ORA-20000: Cursor projection contains an invalid data structure.
    ORA-06512: at "BILLY.FOOPROC", line 19
    ORA-06512: at line 1
    
    // DYNAMIC SQL AND DYNAMIC SQL PROJECTION
    SQL> create or replace procedure FooProc( sqlSelect varchar2 ) is
      2          c               integer;
      3          rc              integer;
      4          colCnt          integer;
      5          fetchCnt        integer;
      6          projection      DBMS_SQL.DESC_TAB;
      7  begin
      8          --// ceate and parse the cursor
      9          c := DBMS_SQL.open_cursor;
     10          DBMS_SQL.parse(
     11                  c,
     12                  sqlSelect,
     13                  DBMS_SQL.native
     14          );
     15
     16          rc := DBMS_SQL.execute( c );
     17
     18          --// describe the sql projection
     19          DBMS_SQL.describe_columns( c, colCnt, projection );
     20
     21          --// the sql projection's fields/columns
     22          DBMS_OUTPUT.put_line( 'SQL projection:' );
     23          for i in 1..colCnt loop
     24                  DBMS_OUTPUT.put_line( '- '||projection(i).col_name );
     25          end loop;
     26
     27          --// fetch and process
     28          fetchCnt := 0;
     29          loop
     30                  rc := DBMS_SQL.fetch_rows( c );
     31                  exit when rc = 0;
     32                  --// use DBMS_SQL.column_value() to read fetched row's columns
     33                  fetchCnt := fetchCnt + 1;
     34          end loop;
     35          DBMS_OUTPUT.put_line( fetchCnt||' row(s) fetched.' );
     36
     37          DBMS_SQL.close_cursor( c );
     38  end;
     39  /
    
    Procedure created.
    
    SQL>
    SQL> exec FooProc( 'select object_id, object_name from user_objects' );
    SQL projection:
    - OBJECT_ID
    - OBJECT_NAME
    143 row(s) fetched.
    
    PL/SQL procedure successfully completed.
    
  • Dynamic cursors

    Hello

    I'm working on dynamic cursors.
    When I try to run the code below, I get the following error.
    BEGIN
      DYNAMIC_CURSOR.OPENCURSOR();
    END;
    
    exception raised ORA-00932: inconsistent datatypes: expected - got -
      
    Here is my code:
    CREATE OR REPLACE
    PACKAGE BODY dynamic_cursor AS
        PROCEDURE dyn_sel (
            tab_name   IN VARCHAR2, 
            field_name IN VARCHAR2, 
            val        IN VARCHAR2, 
            crs        IN OUT t_crs)
        IS 
            stmt VARCHAR2(200); 
        BEGIN 
            stmt := 'select * from '|| tab_name || ' where '|| field_name ||  ' = :1';
            OPEN crs FOR stmt USING val;
        END dyn_sel; 
    
        PROCEDURE openCursor IS 
            tc t_crs; 
            f1 VARCHAR2(50); 
            f2 VARCHAR2(50); 
        BEGIN 
            dyn_sel ('EMP','JOB','MANAGER', tc); 
            LOOP
                FETCH tc INTO f1, f2; 
                EXIT WHEN tc%notfound; 
                dbms_output.put_line (f2); 
            END LOOP; 
        EXCEPTION 
            WHEN OTHERS THEN
                dbms_output.put_line ('exception raised '||SQLERRM);
        END openCursor; 
    END dynamic_cursor; 
    -Thank you

    The selected columns must match the INTO clause, you'll need to extract exactly two columns, for example in

     ...
      stmt := 'select ename, job from ' || tab_name || ' where ' || field_name || ' = :1';
    ....
    
  • ORA-10173: time-out of dynamic sampling error: application of OBIEE 11 g

    Hello

    Application: OBIEE 11g

    Database: Oracle Database Enterprise Edition Release 12.1.0.2.0 - 64 bit Production 12 c

    The following alert was generated for the purposes of OBIEE 11 g database.


    ORA-10173: time-out of dynamic sampling error:


    When I google it finds that there is no resolution except that raise to Oracle.


    Anyone experienced the same and any resulting resolution already?


    Enjoy the you entries.


    Thank you

    HESH

    Thanks Christian, I'll close this thread and open a new forum of the database.

  • Using using Cluase for dynamic cursors using Bind Variables.

    Hello

    I have a quick question. I build dynamic cursor depends on the setting. The one here is my common charly.

    I use the 5 parameter in place several in my query. So, I use almost 40 values if I used with would adopt it. Is there another way to manage rather than spend 40 times.
    SELECT
            decode(GROUPING(nvl2(p_level5, nvl(hier.LVL6,''UNKNOWN''), nvl2(p_level4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(p_level3, nvl(hier.LVL4,''UNKNOWN''), nvl2(p_level2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(p_level1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN''))))))), '1', 'Total',
              nvl2(p_level5, nvl(hier.LVL6,''UNKNOWN''), nvl2(p_level4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(p_level3, nvl(hier.LVL4,''UNKNOWN''), nvl2(p_level2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(p_level1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN''))))))) NAME,
              SUM(kpi),
              .....
    from  tb_test1,...
    where  WHERE upper(nvl(LVL1, ''UNKNOWN'')) = upper(nvl(p_level1, LVL1))
            AND upper(nvl(LVL2, ''UNKNOWN'')) = upper(nvl(p_level2, LVL2))
            AND upper(nvl(LVL3, ''UNKNOWN'')) = upper(nvl(p_level3, LVL3))
            AND upper(nvl(LVL4, ''UNKNOWN'')) = upper(nvl(p_level4, LVL4))
            AND upper(nvl(LVL5, ''UNKNOWN'')) = upper(nvl(p_level5, LVL5))
            AND upper(nvl(LVL6, ''UNKNOWN'')) = upper(nvl(p_level6, LVL6))
          GROUP BY ROLLUP(nvl2(p_level5, nvl(hier.LVL6,''UNKNOWN''), nvl2(p_level4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(p_level3, nvl(hier.LVL4,''UNKNOWN''), nvl2(p_level2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(p_level1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN'')))))))
          ORDER BY nvl2(p_level5, nvl(hier.LVL6,''UNKNOWN''), nvl2(p_level4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(p_level3, nvl(hier.LVL4,''UNKNOWN''), nvl2(p_level2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(p_level1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN''))))));
    Appreciated your help.

    Kind regards
    Vincent.

    Just capture once inside SQL, then use local versions of their

    for example

    with t as (select p_level1 as pl1
                     ,p_level2 as pl2
                     ,p_level3 as pl3
                     ,p_level4 as pl4
                     ,p_level5 as pl5
               from dual)
    SELECT
            decode(GROUPING(nvl2(pl5, nvl(hier.LVL6,''UNKNOWN''), nvl2(pl4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(pl3, nvl(hier.LVL4,''UNKNOWN''), nvl2(pl2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(pl1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN''))))))), '1', 'Total',
              nvl2(pl5, nvl(hier.LVL6,''UNKNOWN''), nvl2(pl4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(pl3, nvl(hier.LVL4,''UNKNOWN''), nvl2(pl2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(pl1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN''))))))) NAME,
              SUM(kpi),
              .....
    from  t, tb_test1,...
    where  WHERE upper(nvl(LVL1, ''UNKNOWN'')) = upper(nvl(pl1, LVL1))
            AND upper(nvl(LVL2, ''UNKNOWN'')) = upper(nvl(pl2, LVL2))
            AND upper(nvl(LVL3, ''UNKNOWN'')) = upper(nvl(pl3, LVL3))
            AND upper(nvl(LVL4, ''UNKNOWN'')) = upper(nvl(pl4, LVL4))
            AND upper(nvl(LVL5, ''UNKNOWN'')) = upper(nvl(pl5, LVL5))
            AND upper(nvl(LVL6, ''UNKNOWN'')) = upper(nvl(p_level6, LVL6))
          GROUP BY ROLLUP(nvl2(pl5, nvl(hier.LVL6,''UNKNOWN''), nvl2(pl4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(pl3, nvl(hier.LVL4,''UNKNOWN''), nvl2(pl2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(pl1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN'')))))))
          ORDER BY nvl2(pl5, nvl(hier.LVL6,''UNKNOWN''), nvl2(pl4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(pl3, nvl(hier.LVL4,''UNKNOWN''), nvl2(pl2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(pl1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN''))))));
    
  • How to declare a dynamic cursor % rowtype?

    Hi guys

    I need to declare a variable of a dynamic cursor rowtype. Is this possible?
    The porpouse this is to store this train in a pl/sql table.

    Example:

    DECLARE
    T_CURSOR IS REF CURSOR TYPE
    MY_C IS T_CURSOR;
    MY_RT IS MY_C % ROWTYPE;
    IS OF TYPE MY_TABLE TABLE OF INDEXES MY_RT BY BYNARI_INTEGER;

    BEGIN
    MY_C OPEN FOR ' SELECT * FROM MYTABLE ';
    SEARCH MY_C MY_TABLE (1);
    SEARCH MY_C MY_TABLE (2);
    SEARCH MY_C MY_TABLE (3);
    LOOK FOR MY_C IN...
    END;

    Obviously this Don t work, but do someone know how I can do something to get the same result?

    Thank you

    Alex Tutor wrote:

    I need to declare a variable of a dynamic cursor rowtype. Is this possible?

    Is not possible. You know upfront structure returned by ref cursor or, if you are in 11g, convert it into cursor DBMS_SQL, retrieves the structure and convert it back (or treat it in DBMS_SQL).

    SY.

  • Sql dynamic cursor or ref or what

    I look on the internet for solutions to this problem and cannot say whether or not I need is dynamic sql, a Ref Cursor or what. I see pieces of what I'm trying to do on various web pages, but nothing which is close.

    In a PL/SQL program, I read a file and perform operations based on these data. Here's my problem:

    I have a select in my PL/SQL program based on something I read from the file and data, I put in a temporary variable earlier in the program.
    Select fielda, fieldb
    in tempvara, tempvarb
    FROM table1
    where fielda = fieldfromdatafile
    and fieldb = tempvar1;

    The problem is that I have more than one record that matches this criterion in the table. If I get a is not a single group group function error (ORA-00937).

    When I think about doing a cursor, the cursor will have different or no data in this document, based on the results of the query.

    If I try to build a select statement to run, then it will bomb because I have several recordings to come back.

    I've never done ref Cursor and do not seem to understand how it would be useful for this. I looked at the ref Cursor definitions by searching on google, but maybe I should have done something else?

    Any ideas? Thank you

    VIC

    Your condition is not exactly clear that you have not provided and the example data and the expected results (or given the version of your database).

    Here is a link that will help you understand what the ref Cursor:

    [PL/SQL 101: understanding Ref Cursor | http://forums.oracle.com/forums/thread.jspa?threadID=886365&tstart=0]

  • Ref cursor error message

    Hello expert;

    I have a function that returns a ref cursor, but the function may not return anything. I would like to know what is the best way to manage the error message

    ORA-06503: PL/SQL: function returned no value - slider Ref

    .. Please see below.

    function f_de return latest_cur is
    my_l_cur l_cur;
    
    begin
    open my_l_cur for
    select max(dateadded) as dateadded
    from tbl_test;
    end;
    

    I was wondering what is the best way to manage. I know I could use a count, and if the number is greater than 0, manipulate, but I was looking for the best way to manage it.

    user13328581 wrote:

    Hello expert;

    I have a function that returns a ref cursor, but the function may not return anything. I would like to know what is the best way to manage the error message

    ORA-06503: PL/SQL: function returned no value - slider Ref

    .. Please see below.

    1. latest_cur the f_de function return is
    2. my_l_cur l_cur;
    3. Start
    4. Open the my_l_cur for
    5. Select max (dateadded) as dateadded
    6. of tbl_test;
    7. end;

    I was wondering what is the best way to manage. I know I could use a count, and if the number is greater than 0, manipulate, but I was looking for the best way to manage it.

    by definition a FUNCTION returns a value, but your code isn't working; Therefore, the error is thrown.

    RETURN MY_L_CUR;

    the top line should take place before the END; statement.

  • Cursor error in Flash

    Hello! I've just updated cc animate, and now I can't open my calendar or all windows tool in flash. I can always open a swf and save, but I cannot draw or do something else. Instead of an appropriate cursor, I have this sign of the cross and error. All the patches?

    IMG_20160322_211958346.jpg

    Hello

    It seems that animate CC cannot load the workspace. Please look at the top right side of the CC animate, and click on the triangle pointing down, select one of the listed workspace and then he will be forced to create the workspace.

    Once done, Quit CC Animate and stimulus to ensure that issue been fixed permanently.

    Kind regards

    Vivek

  • REF CURSOR ERROR

    I get the following error when you try to select using a ref cursor

    SQL error: ORA-06504: PL/SQL: return variables of the game results or the query types do not match

    Here are the steps that I have followeed. Can someone tell me what I did wrong.

    -CREATE AN OBJECT

    create or replace type rsn_rec as object
      (
     rsn_cd   varchar2(10),
     rsn_desc  varchar2(30)
    );
    

    -CREATES A TABLE OF OBJECT

    create or replace type rsn_tbl as table of rsn_rec;
    

    PACKAGE/CREATED FUNCTION

    create or replace package pkg_rept_test as
      type refcur is ref cursor;
      function get_rsn return rsn_tbl pipelined;
    end pkg_rept_test;
    create or replace package body pkg_rept_test as
      function get_rsn
        return rsn_tbl pipelined is
          o_cursor refcur;
          rec rsn%ROWTYPE;
        begin
          open o_cursor for 
           select 
            rsn_cd,         
            rsn_desc       
           from rsn;
          loop
            fetch o_cursor into rec;
            exit when (o_cursor%notfound);
            pipe row(rsn_rec(rec.rsn_cd,                                                                                                   rec.rsn_desc)
                             );
          end loop;
          return;
      end;
    end pkg_rept_test;
    

    -THE TABLE SELECTION

    select * from table(pkg_rept_test.get_rsn)
    

    -ERROR
    SQL error: ORA-06504: PL/SQL: return variables of the game results or the query types do not match

    Your code works for me just as you posted.

    Connected to:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    With partitioning, OLAP, Data Mining and Real Application Testing options

    SQL > create table rsn (rsn_cd varchar2 (10), rsn_desc varchar2 (30));

    Table created.

    SQL > insert into rsn values ("cd test", "test description");

    1 line of creation.

    SQL > commit;

    Validation complete.

    SQL > create or replace the rsn_rec as an object type

    2        (

    3 rsn_cd varchar2 (10),

    rsn_desc 4 varchar2 (30)

    5      );

    6.

    Type of creation.

    SQL > create or replace type rsn_tbl in the rsn_rec table;

    2.

    Type of creation.

    SQL > create or replace package pkg_rept_test as

    2 type refcur is ref cursor;

    3 function get_rsn return rsn_tbl in pipeline;

    4 end pkg_rept_test;

    5.

    Package created.

    SQL > create or replace package body pkg_rept_test as

    2 function get_rsn

    3 return rsn_tbl pipeline is

    4 o_cursor refcur.

    5 rec rsn % ROWTYPE;

    6 start

    7. open o_cursor for

    8. Select

    rsn_cd 9,.

    10 rsn_desc

    11 of rsn;

    12 loop

    13 extract o_cursor in rec;

    When exit 14 (o_cursor % notfound);

    line 15 pipe (rsn_rec (rec.rsn_cd, rec.rsn_desc)

    16                               );

    17 end of loop;

    18 return;

    end 19;

    20 end pkg_rept_test;

    21.

    Package body created.

    SQL > select * from table (pkg_rept_test.get_rsn);

    RSN_CD RSN_DESC

    ---------- ------------------------------

    tests of cd test description

  • region dynamic creation error

    Hi am having an error when creating dynamic region am in jdeveloper 11.1.1.7.0. I have two pages got jsff country and other obtained provience adf table they are all inside the header of the Panel and the collection of panels, I created a dynamic region as a result of this https://blogs.oracle.com/shay/entry/adf_dynamic_regions_switching_just

    My problem is when I click on the link provience I get message saying data retrieval, it does not load data, but if I use adf form there is no problem I can switch between the two and load data

    Is #{backingBeanScope.DateValidation.countrytaskflowdefinition} of the dynamic switch taskflow bean?

    In this case must be the bean at least viewScope or pageFlowScope.

    Timo

  • Dynamic link error

    When I go to file > add after effects Composition I have an error: "Could not connect to Adobe After Effects.  "Please check that the Aobde After Effects and Adobe Dynamic Link components are installed"

    Help, please.

    Hello

    For dynamic links to work as expected, you must have Apps on the same exact versions for example, so once the effects on the 2014.2, Media Encoder should also be 2014.2

    Thank you

    Regalo

  • Examination of dynamic cursor and SQL performance

    Hello world

    I'm a researcher on internet forums and oracle for what is best for my case.


    I tried to rebuild indexes. I had two methods, both works very well, but I'm looking for which is preferable from the point of view of performance

    1 - the use of cursor as in the link below.

    http://www.think-forward.com/SQL/rebuildunusable.htm


    2 - using dynamic SQL, that generated the script file, then run it.

    coil rebuildall.sql
    Select "change the index ' |" owner: '. ' || index_name |' rebuild online; '
    from dba_indexes where status = "UNUSABLE."
    spool off;

    @rebuildall.sql


    Thanks in advance. Your help is appreciated.

    In both cases, that you use dynamic SQL statements, I think that there is no difference in terms of performance, use the method you feel most comfortable

    In all cases, you can follow the timestamps (time is set on & set timing on) and connect the outputs

    Best regards
    Alfonso Vicente
    www.logos.com.uy

  • cursor error

    Hi all
    IAM using toad7.0. anonymas simple performance impossible to block query.pls someone can help me...

    DECLARE
    C DATE;
    BEGIN
    CURSOR C1 IS FROM DUAL SELECT SYSDATE;
    BEGIN
    OPEN C1; LOOP
    FETCH C1 IN C; WHEN EXIT C1% NOTFOUND;
    DBMS_OUTPUT. PUT_LINE (C);
    END LOOP; CLOSE C1; END;
    /

    Watch erros as:
    The following error occurred:

    ORA-06550: line 4, column 8:
    PLS-00103: encountered the symbol "C1" when expecting one of the following conditions:

    := . ( @ % ;
    ORA-06550: line 10, column 1:
    PLS-00103: encountered the symbol "/" when expecting one of the following values:

    not end up dominant static of final instantiable order pragma
    manufacturer membership card


    Kind regards
    Tapan

    Hi tapan,.

    Just remove the first STARTS after the declaration of the variable C, because it leaves the declaration of the cursor outside the DECLARE section where it should be.

    In any case, this type of question is better suited for PL/SQL and SQL. Ask next time.

    Kind regards

    Sergio

  • Invalid cursor error

    When I try to run the following pl/sql code, I get error of invalid cursor. Can someone please explain to me where I am doing wrong.
    DECLARE
    CURSOR C1 IS SELECT employee_id,last_name,salary FROM employees;
    
    
    EMP_REC C1%ROWTYPE;
    
    BEGIN
    FOR REC IN C1
    LOOP
    FETCH C1 INTO EMP_REC;
    EXIT WHEN C1%NOTFOUND;
    
    DBMS_OUTPUT.PUT_LINE('Employee Number '||REC.employee_id);
    
    DBMS_OUTPUT.PUT_LINE('Employee Name '||REC.last_name);
    
    DBMS_OUTPUT.PUT_LINE('JOB '||REC.salary);
    END LOOP;
    END;
    Thanks in advance!

    You must decide if you want to open the cursor implicit or explicit:

    You can use:

    Variant1

    DECLARE
    CURSOR C1 IS SELECT employee_id,last_name,salary FROM employees;
    
    BEGIN
    FOR REC IN C1
    LOOP
    
    DBMS_OUTPUT.PUT_LINE('Employee Number '||REC.employee_id);
    
    DBMS_OUTPUT.PUT_LINE('Employee Name '||REC.last_name);
    
    DBMS_OUTPUT.PUT_LINE('JOB '||REC.salary);
    END LOOP;
    END;
    

    Variant2:

    DECLARE
    CURSOR C1 IS SELECT id employee_id, name last_name, id salary FROM arzt where rownum<10;
    
    EMP_REC C1%ROWTYPE;
    
    BEGIN
    open c1;
    loop
    FETCH C1 INTO EMP_REC;
    EXIT WHEN C1%NOTFOUND;
    
    DBMS_OUTPUT.PUT_LINE('Employee Number '||emp_REC.employee_id);
    
    DBMS_OUTPUT.PUT_LINE('Employee Name '||emp_REC.last_name);
    
    DBMS_OUTPUT.PUT_LINE('JOB '||emp_REC.salary);
    END LOOP;
    END;
    

    Published by: hm on 01.08.2011 00:12

Maybe you are looking for