Results 1 to 3 of 3

Thread: Simple example of Oracle Stored Procedure

  1. #1
    Junior Member
    Join Date
    Jan 2006
    Answers
    1

    Simple example of Oracle Stored Procedure

    Please give me a simple example of oracle stored procedure with in out parameter and out parameter and how to execute it?


  2. #2
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Simple example of Oracle Stored Procedure

    create or replace procedure display
    (
    eno in emp.empno%type,
    name out emp.ename%type,
    job out emp.job%type,
    salary out emp.sal%type,
    location out dept.loc%type
    )
    is
    begin
    select ename,job,sal,loc into name,job,salary,location from emp e,dept d
    where e.deptno=d.deptno AND empno=eno;
    end;


    NOTE:----If a procedure contains any OUT or IN OUT parameter, it can't be executed from SQL prompt it must be called from with in an anonymous block.

    To execute the above procedure.

    declare
    name emp.ename%type;
    job emp.job%type;
    salary emp.sal%type;
    location dept.loc%type;
    begin
    display(7839,name,job,salary,location);
    dbms_output.put_line(name||' '||job||' '||salary||' '||location);
    end;


  3. #3
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Thumbs up Re: Simple example of Oracle Stored Procedure

    Sample example of procedure with in out mode ============================================
    Code:
     
    create or replace procedure fact(a in out number) 
    is
    b number:=1; 
    begin 
    for i in 1..a loop 
    b:=b*i; 
    end loop; 
    a:=b; 
    end;
    to execute the procedure from an anonymous block
    ==================================================
    Code:
     
    declare 
    x number; 
    begin x:=&values; 
    fact(x); 
    dbms_output.put_line(x); 
    end;



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact