Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the ultimate-member domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /ledcorps/www/wp/wp-includes/functions.php on line 6114 4.3 DELETE – 대나무숲

4.3 DELETE

출처 http://www.gurubee.net/lecture/1053

아래는 특정 사원 정보를 삭제하는 프로시저 예제이다.

DELETE 예제

 
SQL> CREATE OR REPLACE PROCEDURE Delete_Test
    ( p_empno IN  emp.empno%TYPE )

        IS

        -- 삭제 데이터를 확인하기 레코드 선언 
        TYPE del_record IS  RECORD
        ( v_empno      emp.empno%TYPE,
          v_ename      emp.ename%TYPE,
          v_hiredate    emp.hiredate%TYPE) ;

          v_emp  del_record ;

        BEGIN

        DBMS_OUTPUT.ENABLE;

         -- 삭제된 데이터 확인용 쿼리 
         SELECT empno, ename, hiredate
         INTO v_emp.v_empno, v_emp.v_ename, v_emp.v_hiredate
         FROM emp
         WHERE empno = p_empno ;

        DBMS_OUTPUT.PUT_LINE( '사원번호 : ' || v_emp.v_empno );
        DBMS_OUTPUT.PUT_LINE( '사원이름 : ' || v_emp.v_ename );
        DBMS_OUTPUT.PUT_LINE( '입 사 일 : ' || v_emp.v_hiredate );

        -- 삭제 쿼리 
        DELETE
        FROM emp
        WHERE empno = p_empno ;

        COMMIT;
        
        DBMS_OUTPUT.PUT_LINE( '데이터 삭제 성공 ' );

       END;
 / 

-- DBMS_OUTPUT.PUT_LINE을 출력하기 위해 사용
SQL> SET SERVEROUTPUT ON ;  

-- 7900사원을 삭제
SQL> EXECUTE Delete_Test(7900);
사원번호 : 7900
사원이름 : JAMES
입 사 일 : 81/12/03
데이터 삭제 성공
        

답글 남기기 0

Your email address will not be published. Required fields are marked *