Search

ν”„λ‘œμ‹œμ €

ν”„λ‘œμ‹œμ € (PROCEDURE)

νŠΉμ • 업무λ₯Ό μ²˜λ¦¬ν•˜λŠ” 일련의 μž‘μ—…μ„ ν”„λ‘œκ·Έλž¨μœΌλ‘œ μ €μž₯ν•˜μ—¬ μ‚¬μš©ν•˜λŠ” 객체

ν”„λ‘œμ‹œμ € 생성

β€’
νŒŒλΌλ―Έν„° μ—†λŠ” ν”„λ‘œμ‹œμ €
CREATE OR REPLACE PROCEDURE ν”„λ‘œμ‹œμ €λͺ… IS | AS μ„ μ–ΈλΆ€ BEGIN μ‹€ν–‰λΆ€ EXCEPTION μ˜ˆμ™Έ μ²˜λ¦¬λΆ€ END [ν”„λ‘œμ‹œμ €λͺ…];
SQL
볡사
β€’
νŒŒλΌλ―Έν„° μžˆλŠ” ν”„λ‘œμ‹œμ €
CREATE OR REPLACE PROCEDURE ν”„λ‘œμ‹œμ €λͺ… ( νŒŒλΌλ―Έν„°1 [IN / OUT / IN OUT] λ°μ΄ν„°νƒ€μž… [ := κ°’ | DEFAULT κΈ°λ³Έκ°’ ], νŒŒλΌλ―Έν„°2 [IN / OUT / IN OUT] λ°μ΄ν„°νƒ€μž… [ := κ°’ | DEFAULT κΈ°λ³Έκ°’ ], ... ) IS | AS μ„ μ–ΈλΆ€ BEGIN μ‹€ν–‰λΆ€ EXCEPTION μ˜ˆμ™Έ μ²˜λ¦¬λΆ€ END [ν”„λ‘œμ‹œμ €λͺ…];
SQL
볡사

ν”„λ‘œμ‹œμ € μ‹€ν–‰

EXCUTE ν”„λ‘œμ‹œμ €λͺ…; EXCUTE ν”„λ‘œμ‹œμ €λͺ…(인자1, 인자2, ...); EXCUTE ν”„λ‘œμ‹œμ €λͺ…(νŒŒλΌλ―Έν„°1 => 인자1, νŒŒλΌλ―Έν„°2 => 인자2, ...);
SQL
볡사

ν”„λ‘œμ‹œμ € μ‚­μ œ

DROP PROCEDURE ν”„λ‘œμ‹œμ €λͺ…;
SQL
볡사

ν”„λ‘œμ‹œμ € μ˜ˆμ‹œμ½”λ“œ

νŒŒλΌλ―Έν„° μ—†λŠ” ν”„λ‘œμ‹œμ €

β€’
ν”„λ‘œμ‹œμ € 생성
-- ν”„λ‘œμ‹œμ € 생성 CREATE OR REPLACE PROCEDURE pro_print IS V_A NUMBER := 10; V_B NUMBER := 20; V_C NUMBER; BEGIN V_C := V_A + V_B; DBMS_OUTPUT.PUT_LINE('V_C : ' || V_C); END; /
SQL
볡사
β€’
ν”„λ‘œμ‹œμ € μ‹€ν–‰
EXCUTE pro_print();
SQL
볡사

νŒŒλΌλ―Έν„° μžˆλŠ” ν”„λ‘œμ‹œμ €

β€’
ν”„λ‘œμ‹œμ € 생성
-- ν”„λ‘œμ‹œμ € 생성 CREATE OR REPLACE PROCEDURE PRO_SUM ( NUM1 IN NUMBER, NUM2 IN NUMBER, RESULT OUT NUMBER ) IS BEGIN RESULT := NUM1 + NUM2 ; DBMS_OUTPUT.PUT_LINE('RESULT : ' || RESULT ); END; /
SQL
볡사
β€’
ν”„λ‘œμ‹œμ € μ‹€ν–‰
DECLARE RESULT_VAL NUMBER; BEGIN -- ν”„λ‘œμ‹œμ € 호좜 PRO_SUM( 10, 20, RESULT_VAL ); -- κ²°κ³Ό 좜λ ₯ DBMS_OUTPUT.PUT_LINE( RESULT_VAL ); END; /
SQL
볡사