Oracle 커서 의 간단 한 용법 을 상세 하 게 설명 하 다.

2737 단어 Oacle유표사용법
다음은 Oracle 커서 의 간단 한 용법 을 살 펴 보 겠 습 니 다.구체 적 인 코드 는 다음 과 같 습 니 다.

create or replace procedure NW_DelYW(iOPERATION_ID number,
                 sUserID   varchar2) is
 sCurDJBH yw_operation_link.djbh%type;
 cursor table_yw(ywid yw_operation.id%type) is
  select * from yw_operation_link t1 where t1.operation_id = ywid;
begin
 for dr in table_yw(iOPERATION_ID) loop
  sCurDJBH := dr.djbh;
  --  opercationid
  /*  select t1.operation_id
   into sOperationID
   from yw_operation_link t1
  where t1.djbh = sCurDJBH;*/

  --   
  insert into log_zfywinfo
   (DJBH,
    DJDL,
    DJXL,
    DLMC,
    XLMC,
    SLR,
    SLRID,
    SQRXM,
    FWZL,
    ZFRQ,
    ZFRID,
    zfr)
   select distinct sCurDJBH,
       t4.id,
       t3.id,
       t4.name,
       t3.name,
       t1.slry,
       t1.slryid,
       t1.SQRXM,
       t1.zl,
       sysdate,
       sUserID,
       (select tt.name from pw_user tt where tt.id=sUserID)
    from yw_operation t1
    join yw_operation_link t2
     on t2.operation_id = t1.ID
    join BUSINESS_TYPE t3
     on t3.id = t1.business_id
    join BUSINESS_CLASS t4
     on t4.id = t3.parent_id
    where t1.ID = dr.operation_id;
exception
 when others then
  rollback;
  dbms_output.put_line(sqlerrm);
end NW_DelYW;
Oracle 은 cursor 커서 순환 을 사용 하여 삭제 업 데 이 트 를 추가 합 니 다.
지식 포인트 확장:
Oracle 커서 단순 예시
커서 를 사용 하여 직원 의 이름과 월급 을 인쇄 하 다.

set serveroutput on;
declare
cursor cemp is select ename,sal from emp;
cname emp.ename%type;
csal emp.sal%type;
begin
 open cemp;
 loop
  fetch cemp into cname,csal;
  exit when cemp%notfound;
  dbms_output.put_line(cname || '    ' || csal);
 end loop;
end;
/ 
 매개 변수 가 있 는 커서
커서 를 사용 하여 모 부서 번호 의 모든 직원 의 이름 을 인쇄 하 다.

set serveroutput on;
declare 
cursor cemp(cno emp.deptno%type) is select ename from emp where emp.deptno = cno;
cname emp.ename%type;
begin
 open cemp(10);
 loop 
  fetch cemp into cname;
  exit when cemp%notfound;
  dbms_output.put_line(cname);
  
 end loop;
end;
/ 
총결산
위 에서 말 한 것 은 소 편 이 여러분 에 게 소개 한 Oracle 커서 의 간단 한 용법 입 니 다.여러분 에 게 도움 이 되 기 를 바 랍 니 다.만약 에 궁금 한 점 이 있 으 면 저 에 게 메 시 지 를 남 겨 주세요.소 편 은 제때에 여러분 에 게 답 할 것 입 니 다.여기 서도 저희 사이트 에 대한 여러분 의 지지 에 감 사 드 립 니 다!
만약 당신 이 본문 이 당신 에 게 도움 이 된다 고 생각한다 면,전 재 를 환영 합 니 다.번 거 로 우 시 겠 지만 출처 를 밝 혀 주 십시오.감사합니다!

좋은 웹페이지 즐겨찾기