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!

PL/SQL Programming Suggestion

Discussion in 'SQL PL/SQL' started by jakirajam, Mar 6, 2010.

  1. jakirajam

    jakirajam Active Member

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    55
    Hi Techies,

    I am new to oracle PL/SQL programming. I am not getting the output. Can anyone suggest me?

    Code (SQL):
    DECLARE
      vemp  emp%rowtype;  
      BEGIN
        SELECT sal INTO vemp  FROM  emp
    WHERE empno=7566;
     dbms_output.put_line('the emp salary is'||vemp.sal);            
      DECLARE
     vemp1 emp%rowtype;
            BEGIN
         SELECT  sal   INTO  vemp1  FROM emp  WHERE
               empno=7839;
       dbms_output.put_line('the emp salary is' ||vemp1.sal);
      --dbms_output.put_line('the emp salary in mode 2'||vemp.sal);
            END;
      END;

    Regards,
    Jakir.
     
  2. kiran.marla

    kiran.marla Forum Genius

    Messages:
    403
    Likes Received:
    52
    Trophy Points:
    505
    Location:
    Khammam
    Hi jakir, in the declare section use %type instead of %rowtype.
     
  3. rajavu

    rajavu Forum Guru

    Messages:
    815
    Likes Received:
    52
    Trophy Points:
    610
    Location:
    @ Bangalore , India
    No . Only On change is needed.

    Replace "SELECT sal INTO" with "SELECT * INTO".

    Code (SQL):

    SQL>
    SQL> DECLARE
      2   vemp  emp%rowtype;
      3  BEGIN
      4       SELECT * INTO vemp  FROM  emp
      5       WHERE empno=7566;
      6         dbms_output.put_line('the emp salary is'||vemp.sal);
      7
      8       DECLARE
      9        vemp1 emp%rowtype;
     10       BEGIN
     11         SELECT  *  INTO  vemp1  FROM emp
     12         WHERE empno=7839;
     13             dbms_output.put_line('the emp salary is' ||vemp1.sal);
     14       END;
     15  END;
     16  /
    the emp salary is2975
    the emp salary is5000

    PL/SQL PROCEDURE successfully completed.

    SQL>