PL/SQL基本操作

1、常规过程化形式

declare
  o_booking_flag char(10);
begin
 
  -- Call the procedure
  destine_ticket('000000037',
                 20,
                 'E',
                 2,
                 o_booking_flag);
                dbms_output.put_line(o_booking_flag);
end;

2、存储过程

create or replace procedure destine_ticket(i_flightId     in char, --不需要些类型值
                                           i_LuggageLimit in number ,
                                           i_class_code in char ,
                                           i_seats in number,
                                           o_booking_flag out char 
                                           ) 
is
  v_temp integer;
  v_temp1 integer;
begin

    begin
       select 1 into v_temp from flight  t1 where t1.flightid=i_flightId and to_number(t1.estdeparturedatetime-sysdate)*24 >= 3;
    exception --异常捕获
    when no_data_found then
         v_temp:=0; --复制要写:=
    end;
  return; --退出存储过程
end destine_ticket;

 3、过程调用

declare
  o_booking_flag char(10);
begin
 
  -- Call the procedure
  destine_ticket(i_flightid =>'000000037',
                 i_luggagelimit =>20,
                 i_class_code =>'E',
                 i_seats =>2,
                 o_booking_flag =>o_booking_flag);
end;

猜你喜欢

转载自www.cnblogs.com/gered/p/10918435.html