트리거, 함수, 저장 프로세스, 실행 문장 만들기

1. 실행 문장 만들기
declare 
       cursor venList is select * from tbl_venue ;
begin
       --for 
       for ven in venList loop
          dbms_output.put_line(' :'||VEN.id); 
      end loop;
      --COMMIT;
end ;

2, 트리거 만들기
create or replace trigger  
  after/before INSERT OR UPDATE OR DELETE on  
  for each row
declare
  mesg varchar2(100);
begin
  case
    when inserting then
      begin
        mesg := ' ';
          :new , : :new.id 
      EXception when others then 
        dbms_output.put_line(' :' ||:old.id);
      end;
    when updating then
      begin
        mesg := ' ';
          :new , : :new.id 
          :old , : :old.id 
      EXception when others then 
        dbms_output.put_line(' :' ||:old.id);
      end;
    when deleting then
      begin
        mesg := ' ';
          :old , : :old.id 
      EXception when others then 
        dbms_output.put_line(' :' || :old.id);
      end;
  end case;
end;

3. 함수 만들기
(1), 개별 속성
create or replace function getReportDate(param in varchar2 .. .)
  return varchar2 is -- 
  accept_time varchar2(1000);
  v_acc_nbr   date;
  
  CURSOR cur_1 is select sysdate from daul; -- 
begin
  open cur_1; -- 
  loop
    fetch cur_1
      into v_acc_nbr; -- 
    exit when cur_1%notfound;
    if accept_time is null then
      ---- 
    else
      ---- 
    end if;
  end loop;
  close cur_1;
  return(accept_time); -- 
end getReportDate;

(2), 여러 속성 값
create or replace function getReportDate(param in varchar2 .. .)
  return varchar2 is -- 
  accept_time varchar2(1000);
  p1   date;
  p2   date;
  p3   date;
  
  CURSOR cur_1 is select sysdate,sysdate,sysdate from daul; -- 
begin
  open cur_1; -- 
  loop
    fetch cur_1  into p1,p2,p3; -- 
    exit when cur_1%notfound;
    if accept_time is null then
      ---- 
    else
      ---- 
    end if;
  end loop;
  close cur_1;
  return(accept_time); -- 
end getReportDate;

4. 스토리지 프로세스 생성
create or replace procedure   is-- 
--create or replace procedure  (queryPara varchar2.. .) is --   
  sql_set varchar2(1024); -- 
  cursor crData is select * from  ;
begin
  for rowData in crData loop
    -- 
    BEGIN 
      dbms_output.put_line(' :' || rowData.id);
    EXCEPTION WHEN OTHERS THEN
        dbms_output.put_line(' :');
    END;
  end loop;
end  ;

좋은 웹페이지 즐겨찾기