How to use a dynamic cursor

Hi! All, I am trying to create a table at run time and insert values in it and selecting from the created table. my pl/sql does not complie and gives me a error.
DECLARE
rc sys_refcursor;
TYPE t1_row IS RECORD (col1 NUMBER, col2 number(3));
TYPE t1_tab IS TABLE OF t1_row;
v_tab t1_tab;
v_table_name varchar2(10);
v_col1 number:=1;
v_col2 number:=111;
BEGIN
execute immediate 'create table t1 (id number, name number)';
execute immediate 'insert into t1(id, name) values(:v_col1, :v_col1)' using v_col1, v_col2;
OPEN rc FOR 'SELECT id, name FROM t1';
FETCH rc INTO v_tab;
FOR i IN 1..1 LOOP
dbms_output.put_line(v_tab(i).col1||'::'||v_tab(i).col2);
END LOOP;
END;
the above code gives me a error.Could any 1 pease help.
ERROR at line 13:
ORA-06550: line 13, column 20:
PLS-00597: expression 'V_TAB' in the INTO list is of wrong type
ORA-06550: line 13, column 5:
PL/SQL: SQL Statement ignored
Regards,
Ritesh
Message was edited by:
[email protected]
Message was edited by:
[email protected]
Message was edited by:
[email protected]

DECLARE
rc sys_refcursor;
TYPE t1_row IS RECORD (col1 NUMBER, col2
col2 number(3));
TYPE t1_tab IS TABLE OF t1_row;
v_tab t1_tab;
BEGIN
OPEN rc FOR 'SELECT id, name FROM t1';
FETCH rc INTO v_tab;
You have to use BULK COLLECT when you use a collection like that:
       FETCH rc BULK COLLECT INTO v_tab;

Similar Messages

  • How to use the Dynamic Expression in BRFplus

    Hi Experts
                   I am new to BRFplus. Can you give any document on BRFplus how to use the Dynamic Expression.
    Thankyou
    Venkat

    OK I tried it and worked but for one condition:
    WHERE DECODE (E.qualification_sid, 1104,
         (TO_DATE(E.RANK_DATE, 'DD-MM-RR')+(365*M.spe_per)+1),
         (TO_DATE(E.RANK_DATE, 'DD-MM-RR')+(365*M.mili_yea_per)+1))
         BETWEEN TO_DATE('01-07-2011', 'DD-MM-RR') AND TO_DATE('31-07-2011', 'DD-MM-RR')
    But how to put two conditions for the same Expression:
    WHERE DECODE ((E.qualification_sid, 1104) AND (E.RANK_SID, 8),
         (TO_DATE(E.RANK_DATE, 'DD-MM-RR')+(365*M.spe_per)+1),
         (TO_DATE(E.RANK_DATE, 'DD-MM-RR')+(365*M.mili_yea_per)+1))
         BETWEEN TO_DATE('01-07-2011', 'DD-MM-RR') AND TO_DATE('31-07-2011', 'DD-MM-RR')
    The previous code gives me this error: missing right parenthesis

  • How to use same dynamic text, multiple times in a Movie

    FLASH CS5.5
    How can a dynamic text field be used multiple times, on any
    frame, in any new layer during a Movie?
    ~~
    A number of unique dynamic text fields are being used.
    The intent is to use them each, many times during a Movie.
    (i.e. a users first name)
    They are successfully being "ExternalInterfaced" from a PDF form field.
    (the SWF is displayed within the PDF as a RMA)
    This all works well, IF I only use one instance of the dynamic text field.
    (one use of each unique text field)
    If I try and use that same dynamic text field, again, in a new layer, later in the SWF,
    all of that said, duplicate dynamic text fields do not display.
    ~~
    Stumped!!!
    Thanks in advance for your advice / comments!
    D-

    Thanks Ned,
    I always welcome learning something new.
    I did not know creating a new keyframe,
    creates a new instance.
    Yes, I had used the same dynamic text field instance name in
    numerous, new layers (great observation).
    With the objective to display the User's name throughout
    the timeline (on and off)...
    I'll attempt to paraphrase your solution;
    Use a single layer to display the dynamic text field.
    Extend this layer's timeline throughout the movie, or end use of the dynamic text field.
    Help with this one ??
    Set the visible properties to true or false as need through out the timeline.
    ( Does require an AS3 ? )
    I'll give that a try.....
    ~~
    Side of effect of using the above solution;
    The SWF in it's attempted state, uses the dynamic text field instance, in
    different places, different text sizes, on the stage, throughout the Movie.
    (i.e. the User's first name appears in different sentences...)
    Per the solution above,
    I believe I will be limited to One location, one format setting.
    Is this assumption correct?
    I can make this work from a display / Movie point of view.
    However, your first VAR concept, noted above, might be
    worth exploring should more flexibility be required.
    Thanks for making the time to coach...
    D-

  • How to use the Dynamic Configuration Bean

    Hi experts,
    im currently doing a file to mail scenario.
    i want the name of the input file as the subject of the mail.
    i want to establish this using the Dynamic Configuration bean
    my first question is:
    key.1 <b>read</b> http://sap.com/xi/XI/System/Mail THeaderSUBJECT
    value.1 message.messageID
    this reads the value of the message ID into the attribute THeaderSUBJECT
    but what does this do?
    key.1 <b>write</b> http://sap.com/xi/XI/System/Mail THeaderSUBJECT
    value.1 message.messageID
    when i use this it has no effect atall.
    my second question.
    I have my input filename in the FileName attribute in Dynamic configuration how can i read it into THeaderSUBJECT attribute.
    Appreciate any suggestions.

    Hi Satish,
    Yep i know its possible via an udf in Message mapping but i dont have an MM in my scenario. Since im not parsing thru the input data since its an excel file, so im transferring the file using the following method
    /people/william.li/blog/2006/09/08/how-to-send-any-data-even-binary-through-xi-without-using-the-integration-repository
    and in this method if i include an MM it will give me a mapping exception.
    So i have to use this bean somehow and try to accomplish what we do in the udf.

  • How to use a Dynamic Transaction Screen Variant

    Hi,
    I'm trying to use a standard variant (ZVA01) asociated to trx VA01.
    I created this transaction variant in order to avoid changes of adresses's fields  of the partners (bill to party)  during the Sales Order creation.
    I set as 'Only Display' this fields.
    The problem we have is that, we also have 'One Time customers', in this case those blocked fields should be available to change its data during SO creation.
    How can I change dynamically the transaction variant to be used in VA01 , based on
    in the type of cliente (CPD or not CPD) ??
    I have read that there exists a DYNAMIC TRANSACTION VARIANTs option, but I have  not understood its way of use.
    Could some body give me a link to this topic or explain it ?? .
    Thanks ...
    Regards
    Tania Moreno

    Tania,
    I have never heard of 'DYNAMIC TRANSACTION VARIANT'.  There does exist Dynamic date variables for Variants.
    http://help.sap.com/saphelp_erp60/helpdata/en/c0/980398e58611d194cc00a0c94260a5/frameset.htm
    I think you should probably use a userexit to achieve your business requirements.  Perhaps USEREXIT_FIELD_MODIFICATION
    within include MV45AFZZ.
    Best Regards,
    DB49

  • Please Help!!! How to use the Hand cursor on an Image !!!!

    Hi,
    I am sorry for cross posting but nobody seem to know this, i need this as soon as possible.
    I have a main Jframe which contains a Jpanel which contains a jscrollpane. THe image is in scrollpane and i would like to use the Hand cursor to move the image up and down the jscrollpane.
    Can someone tell me or show me how can i use a hand cursor on an image
    I would appreciate if someone can show me a simple example.
    THanks in advance.

    Well. I would call setCursor with a cursor of type Cursor.HAND_CURSOR or something on the Component where you want the hand. Then you could add a MouseMotionListener to the Component. in mouseDragged() you scroll the scrollpane programmatically according to the MouseEvents getX() and getY().

  • How to use an dynamic text from Flash in FlashBuilder with swf ?

    Hello,
    i'm trying to develop a game in flex builder and i got a problem with the dymanic text i've imported from flash. I want to insert a scoreboard in my application and for doing that i should use dynamic text in flash. I create a dynamic text in flash and then a import it to Flash Builder in a movie clip, and i called the dynamic text "Score". Now i've tried to use the "Score" variable to change the value of the dynamic text box un my flash builder application, but it doesn't change anything.
    I read somewhere that i've got to use the score.text value to change the number of my score but that doesn't works because Flash Builder tells me that this sort of variable don't contain the .text value.
    Thank you for trying to help me.
    bye.

    Thanks Ned,
    I always welcome learning something new.
    I did not know creating a new keyframe,
    creates a new instance.
    Yes, I had used the same dynamic text field instance name in
    numerous, new layers (great observation).
    With the objective to display the User's name throughout
    the timeline (on and off)...
    I'll attempt to paraphrase your solution;
    Use a single layer to display the dynamic text field.
    Extend this layer's timeline throughout the movie, or end use of the dynamic text field.
    Help with this one ??
    Set the visible properties to true or false as need through out the timeline.
    ( Does require an AS3 ? )
    I'll give that a try.....
    ~~
    Side of effect of using the above solution;
    The SWF in it's attempted state, uses the dynamic text field instance, in
    different places, different text sizes, on the stage, throughout the Movie.
    (i.e. the User's first name appears in different sentences...)
    Per the solution above,
    I believe I will be limited to One location, one format setting.
    Is this assumption correct?
    I can make this work from a display / Movie point of view.
    However, your first VAR concept, noted above, might be
    worth exploring should more flexibility be required.
    Thanks for making the time to coach...
    D-

  • How to use Rowid in Cursor

    Hi all,
    Suppose i am updating some Rows in a cursor.
    Can u plz let me know the Syntax of Using ROWID in Cursor with a simple example.plzz
    i am trying to execute the follwing code but it si throwing error.Here i am trying to update salaries of employees who belong tO IT Department and whose salary is <5000
    Declare
    Cursor inc_salary is
    Select e.employee_id,e.salary,e.department_id,d.department_id DEPART
    from employees e,departments d
    where e.department_id=d.department_id
    and d.department_id='IT'
    and e.salary<5000 FOR UPDATE OF SALARY;
    Begin
    For inc_record in inc_salary
    Loop
    DBMS_OUTPUT.PUT_LINE('Employee Id is '||inc_record.employee_id);
    DBMS_OUTPUT.PUT_LINE('Original Salary is '||inc_record.salary);
    DBMS_OUTPUT.PUT_LINE('Department No in Employees Table is '||inc_record.department_id);
    DBMS_OUTPUT.PUT_LINE('Department No in Departments Table is '||inc_record.DEPART);
    End Loop;
    DBMS_OUTPUT.PUT_LINE('Lets Now increase the Salary of Employees');
    DBMS_OUTPUT.PUT_LINE('********************************');
    For inc_record in inc_salary
    Loop
    Update employees
    Set Salary=5000
    where Rowid=inc_salary.rowid;
    End Loop;
    End;
    Edited by: user12920808 on Aug 19, 2012 4:39 AM

    You update within
    For inc_record in inc_salarywhere inc_salary is a cursor and inc_record is a record where rows inc_salary are fetched into. While in update statement you are referencing cursor.column instead or record. column. You need to change:
    where Rowid=inc_salary.rowid;to
    where Rowid=inc_record.rowid;However, cursor inc_salary doesn't include employees.rowid, so you need to add it. And it should be department_name = 'IT', not department_id:
    Declare
    Cursor inc_salary is
    Select e.employee_id,e.salary,e.department_id,d.department_id DEPART,e.rowid e_rowid
    from employees e,departments d
    where e.department_id=d.department_id
    and d.department_name='IT'
    and e.salary<5000 FOR UPDATE OF SALARY;
    Begin
    For inc_record in inc_salary
    Loop
    DBMS_OUTPUT.PUT_LINE('Employee Id is '||inc_record.employee_id);
    DBMS_OUTPUT.PUT_LINE('Original Salary is '||inc_record.salary);
    DBMS_OUTPUT.PUT_LINE('Department No in Employees Table is '||inc_record.department_id);
    DBMS_OUTPUT.PUT_LINE('Department No in Departments Table is '||inc_record.DEPART);
    End Loop;
    DBMS_OUTPUT.PUT_LINE('Lets Now increase the Salary of Employees');
    DBMS_OUTPUT.PUT_LINE('********************************');
    For inc_record in inc_salary
    Loop
    Update employees
    Set Salary=5000
    where Rowid=inc_record.e_rowid;
    End Loop;
    End;
    Employee Id is 105
    Original Salary is 4800
    Department No in Employees Table is 60
    Department No in Departments Table is 60
    Employee Id is 106
    Original Salary is 4800
    Department No in Employees Table is 60
    Department No in Departments Table is 60
    Lets Now increase the Salary of Employees
    PL/SQL procedure successfully completed.
    SQL> And why do you have two loops instead of one. All you need is:
    SQL> Declare
      2  Cursor inc_salary is
      3  Select e.employee_id,e.salary,e.department_id,d.department_id DEPART,e.rowid e_rowid
      4  from employees e,departments d
      5  where e.department_id=d.department_id
      6  and d.department_name='IT'
      7  and e.salary<5000 FOR UPDATE OF SALARY;
      8  Begin
      9  For inc_record in inc_salary
    10  Loop
    11  DBMS_OUTPUT.PUT_LINE('Employee Id is '||inc_record.employee_id);
    12  DBMS_OUTPUT.PUT_LINE('Original Salary is '||inc_record.salary);
    13  DBMS_OUTPUT.PUT_LINE('Department No in Employees Table is '||inc_record.department_id);
    14  DBMS_OUTPUT.PUT_LINE('Department No in Departments Table is '||inc_record.DEPART);
    15  Update employees
    16  Set Salary=5000
    17  where Rowid=inc_record.e_rowid;
    18  End Loop;
    19  End;
    20  /
    Employee Id is 105
    Original Salary is 4800
    Department No in Employees Table is 60
    Department No in Departments Table is 60
    Employee Id is 106
    Original Salary is 4800
    Department No in Employees Table is 60
    Department No in Departments Table is 60
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Using a Dynamic cursor

    Hi,
    I have a problem with this code :
    DECLARE
         v_Column_Name           all_tab_columns.column_name%TYPE;      -- variable for TABLE_SQL
         v_data_type           all_tab_columns.data_type%TYPE;      -- variable for CHPS_SQL
         v_Table_Name           user_tables.table_name%type;
         lc$results     VARCHAR2(32767) := null;
         lc$Champ     VARCHAR2(32767) := null;
         lc$Requete     VARCHAR2(32767) := null;
         CURSOR C1 IS
              SELECT table_name FROM user_tables;
    BEGIN
         OPEN C1;
         LOOP
              FETCH C1 INTO V_Table_name;
              EXIT WHEN C1%NOTFOUND;
              DECLARE
                   CURSOR C2 IS
                        select column_name, data_type from all_tab_columns where table_name = V_TABLE_NAME;
              BEGIN
                   lc$results := 'INSERT INTO ' || v_table_name || '(';
                   lc$requete := 'SELECT ' ;
                   lc$Champ := NULL;
                   OPEN C2;
                   LOOP
                        FETCH C2 INTO V_column_name, V_data_type;
                        EXIT WHEN C2%NOTFOUND;
                        if lc$Champ IS NOT NULL then
                             lc$Champ := lc$champ || ',' || v_column_name;
                             lc$requete := lc$requete || ',' || '''''''''' || ',' || v_column_name || ',' || '''''''''';
                        else
                             lc$champ := lc$champ || v_column_name;
                             lc$requete := lc$requete || '''''''''' || ',' || v_column_name || ',' || '''''''''';
                        end if;
                   END LOOP;
                   CLOSE C2;
                   lc$results := lc$results || lc$champ || ') VALUES (';
                   lc$requete := lc$requete || ' FROM ' || v_table_name;
    -- MY PROBLEM BEGIN HERE
                   DECLARE
    *                    TYPE EmpCurTyp IS REF CURSOR;*
    *                    C3     EmpCurTyp;*
    *               BEGIN*
    *                    OPEN C3 FOR lc$requete;*
    *                    lc$champ := NULL;*
    *                    LOOP*
    *                         FETCH C3 INTO lc$champ ;*
    *                         Exit when C3%NOTFOUND ;*
    *                         lc$champ := lc$results || lc$champ || ')';*
    *                         dbms_output.put_line(lc$champ);*
    *                    END LOOP;*
    *                    CLOSE C3;*
    *               END;*
              END;
         END LOOP;
         CLOSE C1;
    END;          
    the error code is : ORA-00932: inconsistent datatypes: expected - got -
    Need help please,
    Thank

    904907 wrote:
    How can I use the dbms_SQL for this code?99% of the time this indicates design issues. You are trying to write "one-size-fits-all" code which by definition will have substantial overhead. Other than that, in general, you need to declare a variable for each data type possibly returned by dynamic SQL. Then use DBMS_SQL.DESCRIBE_COLUMNS to get data types of select list expressions. Fetch a row and then loop from 1 to number of select list expressions where loop body is one giant IF to test select list expression datatype and issue corresponding DBMS_SQL.COLUMN_VALUE into proper data type variable.
    SY.

  • How to use one dynamic connection managers for multiple parallel data flow tasks

    hi there:
       I have 6 databases residing on the same server. What I want to do is  call a store procedure with identical name on each database dbo schema and transport results to a centralized place. The key is to have those SPs run in parallel instead
    of in sequence as each SP may take around 10 mins to finish. 
    The simplest way is to create 6 OLE DB connection managers and create 6 DFT tasks. However, I do not want to maintain 6 OLE DB connection managers as there is a chance to have more connection  managers.
     What I did so far is to create a OLD DB connection manager and use expression to set up connectionString properties so that it will get populated by variables at run time. It is fine when running all SPs in a Foreach Loop Container. However, it takes
    around 60 mins to finish.
      When I try to run it in parallel ( basically created 6 DFTs but use only one Dynamic Connection Manager), the connection string gets confused therefore all DFT tasks failed.
       Does anyone here have some experience on this topic?
    Thanks
     hui
    --Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --

    Yes, basically, on the connectionString property of ONE OLEDB, you are using an expression to supply value and this expression is pointing to a variable. 
    In this case , you can update this variable from a table which contains many connection strings. It's good if you want to execute Store procedures in a sequential order. When in parallel mode, this will cause issues as connectionString gets overwritten. 
     I am thinking about using script task to exec sp.
     The whole idea is that I do not want to maintain a large number of Connection Managers. 
    Hope it helps
    --Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --
    So you are not able to run parallel executions using same conn mgmr, even with dynamic connectionstring, is that correct? Yes, script task will be a way to go if you wish to execute it in parallel, you may connect to SS and query the proper conn string with
    SELECT/WHERE clause in each script > pass it to a script variable > use that script variable and execute the proc. This will require only two things to change in each script, the WHERE condition to get the conn string and the proc name (you may even
    get the proc names the same way you get conn string) and everything else will be same. Let us know how that goes. 
    Hope no two or more procs doing insert/update/delete on the same tables.

  • How to use customize mouse cursor?

    Hello everyone
    i want to use my own pictures as the mouse cursor. How can I make it?
    Thank you

    Try using ToolKit.getDefaultToolKit().createCustomCursor() as a first step.

  • How to use the Dynamic register of events in X-controls

    Is it possible to handle dynamic events triggering using the X-control and if possible how to handle that option

    Yes, it is tricky.  I have an idea on the Idea Exchange suggesting that this behaviour is added to XControls - go and give kudos if you agree.
    http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Trigger-XControls-for-Dynamic-Events/idi-p/1411062

  • How to use a dynamic SQL data as the header ?

    I'm using BO XI Rel 2. I have hard coded the report headers, but i do have a table wherein the header data is available. I like to fetch the HEADER information from the table, rather than hard coding. How to go about it?
    Example: "Statement of Closing" is the header.
    The above output can be retrieved by using the below query!
    Select Form_desc from TBS_FORMS where form_id = 'tbs1a';
    form_id is a common link between tables!! Since the actual report data has multiple value as output, just by plugging the query in the header, i'm getting #multivalue error!!!!
    In oracle reports, i have something called place holder to achieve the above objective. In BO, how to go about it?
    Edited by: Karthik  Ganesan on Dec 28, 2008 1:22 PM

    Sorry, that doesn't solve my problem. Please read the question more closely - I want my USERS to be able to do this without changing their configurations. My users are public school elementary teachers and parents. I can't ask them to toggle any settings - I'm looking for a way that my users can do this on their own.
    Thanks

  • How to use the dynamical or static variable for ESSBASE cube name?

    Hi Experts,
    When I import ESSBASE Cube into physical layer, the cube name from ESSBASE is created automatically, such as H_Sales.
    I want to use the the static or dynamical variable for replacing the external name. So I try to create the static variable in RPD,such as cubeName, and use the following code
    'VALUEOF(cubeName)' into the textbox of external name.
    However, when I view the report in answer, it will generate the error message: Database VALUEOF(cubeName) does not exist.
    Is it possible to implement this functionality?
    Thanks..

    Hi,
    use <%=odiRef.getSchemaName("D")%>
    D as parameter if it is the Data Schema or W if you need the schema from Work Schema
    Your command will be like:
    select <%=odiRef.getSchemaName("D")%>.GER_LOT_EXEC_ODI('Fluxo', 1, 'C') FROM DUAL
    Works?
    Cezar Santos
    http://odiexperts.com

  • HOW TO CREATE A DYNAMIC CURSOR?

    hi, i have a cursor that i declared it in first_line of my package.
    create or replace package ....
    CURSOR ACCESS_VIEW IS SELECT * FROM SYS.ALL_OBJECTS;
    PROCEDURE PUT...
    FOR REC IN ACCESS_VIEW
    LOOP
    END LOOP;
    in this package and at the first line of 'put' procedure, i will change the ACCES_VIEW CURSOR. how can i do this? pls help me.
    thanx

    in this package and at the first line of 'put' procedure, i will change the ACCES_VIEW CURSOR. how can i do this?
    SQL>  create or replace package pkg
    as
       cursor cur is select * from emp;
       procedure put;
    end pkg;
    Package created.
    SQL>  create or replace package body pkg
    as
       procedure put
       as
       begin
         for c in cur
         loop
            dbms_output.put_line(c.ename);
         end loop;
       end put;
    end pkg;
    Package body created.
    SQL>  exec pkg.put
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    PL/SQL procedure successfully completed.
    @Sundar M:
    SQL>  create or replace package pkg
    as
       cur   sys_refcursor;
    end pkg;
    Warning: compiled but with compilation errors
    SQL>  show error
    Errors for PACKAGE PKG
    LINE/COL                                                                       
    ERROR                                                                          
    3/10                                                                           
    PLS-00994: Cursor Variables cannot be declared as part of a package            
    3/10                                                                           
    PL/SQL: Declaration ignored                                                    

Maybe you are looking for