1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

nested tables in pl/sql

Discussion in 'SQL PL/SQL' started by one nice time, Nov 27, 2012.

  1. one nice time

    one nice time Active Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    55
    let's say i have table emp_test with two columns ename and job both varchar2


    1 DECLARE
    2 TYPE EMP_TAB_TYPE IS TABLE OF EMP_TEST%ROWTYPE;
    3 EMP_TAB EMP_TAB_TYPE;
    4 BEGIN
    5 EMP_TAB:=EMP_TAB_TYPE('john','ENG');
    6 NULL;
    7* END;
    SQL> /
    EMP_TAB:=EMP_TAB_TYPE('john','ENG');
    *
    ERROR at line 5:
    ORA-06550: line 5, column 10:
    PLS-00306: wrong number or types of arguments in call to 'EMP_TAB_TYPE'
    ORA-06550: line 5, column 10:
    PLS-00306: wrong number or types of arguments in call to 'EMP_TAB_TYPE'
    ORA-06550: line 5, column 1:
    PL/SQL: Statement ignored

    --------------------------------------------------------------------------
    how do i assign multi column to this nested table , can any one advise?
     
  2. Bharat

    Bharat Community Moderator Forum Guru

    Messages:
    1,747
    Likes Received:
    147
    Trophy Points:
    1,805
    Location:
    Vijayawada, India
    Please post the table(EMP_TEST) structure.
     
  3. ac.arijit

    ac.arijit Forum Advisor

    Messages:
    217
    Likes Received:
    22
    Trophy Points:
    280
    Location:
    Kolkata, India
  4. dariyoosh

    dariyoosh Forum Advisor

    Messages:
    118
    Likes Received:
    19
    Trophy Points:
    260

    Hello there,

    You can try this

    Code (Text):

    DECLARE
        TYPE emp_ntab IS TABLE OF emptab%ROWTYPE;
        l_ntab_emps emp_ntab := emp_ntab();
        l_emp emptab%ROWTYPE;
    BEGIN
        l_emp.ename := 'John';
        l_emp.job := 'ENG';
        l_ntab_emps.EXTEND;
        l_ntab_emps(1) := l_emp;
        DBMS_OUTPUT.PUT_LINE(l_ntab_emps(1).ename || '  ' || l_ntab_emps(1).job);
    END;
    /
     


    Regards,
    Dariyoosh
     
  5. dariyoosh

    dariyoosh Forum Advisor

    Messages:
    118
    Likes Received:
    19
    Trophy Points:
    260
  6. one nice time

    one nice time Active Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    55
    thank you all appreciated.
     
  7. Bharat

    Bharat Community Moderator Forum Guru

    Messages:
    1,747
    Likes Received:
    147
    Trophy Points:
    1,805
    Location:
    Vijayawada, India
    Please post the results if you successfully finished it. By that it will be helpful to others to know whats the issue behind that.