pl/sql procedure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhu50
    New Member
    • Jun 2007
    • 20

    pl/sql procedure

    i have coded following program for taking losal and hi sal from table salgrade and now using procedure add2 that is following:-


    create or replace procedure add2(a in number,b in number,c out number) is
    begin
    c:=a+b;
    end;

    procedure is created successfully but want to display total salary=losal+hi sal
    using this procedure named as add2 for this i have coded following program and i got error msg that
    "invalid sql statement"
    hav i written my sql statement is not correct plz solve this problem


    decalre
    lo salgrade.losal% type;
    hi salgrade.hisal% type;
    t number;
    begin
    select losal,hisal into lo,hi from salgrade where grade=2;
    add2(lo,hi,t);
    dbms_output.put _line('total salary is:'||t);
    end;
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by abhu50
    i have coded following program for taking losal and hi sal from table salgrade and now using procedure add2 that is following:-


    create or replace procedure add2(a in number,b in number,c out number) is
    begin
    c:=a+b;
    end;

    procedure is created successfully but want to display total salary=losal+hi sal
    using this procedure named as add2 for this i have coded following program and i got error msg that
    "invalid sql statement"
    hav i written my sql statement is not correct plz solve this problem


    decalre
    lo salgrade.losal% type;
    hi salgrade.hisal% type;
    t number;
    begin
    select losal,hisal into lo,hi from salgrade where grade=2;
    add2(lo,hi,t);
    dbms_output.put _line('total salary is:'||t);
    end;
    Why not make add2 a function instead of a procedure? It doesn't do any DML and returns exactly one value ....

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      Please use

      declare
      not
      decalre

      to start any PL/SQL block.

      silly mistake.

      Comment

      Working...