2014-09-15

[Oracle]有參數Stored Procedures

1、建立測試Table
CREATE TABLE Yulin ( 
    V1 VARCHAR2(30 BYTE),
    V2 VARCHAR2(50 BYTE),
    V3 VARCHAR2(100 BYTE), 
    N1 NUMBER(30),
    N2 NUMBER(30),
    N3 NUMBER(30),
    D1 DATE,
    D2 DATE,
    D3 DATE 
)
2、建立Stored Procedures
	CREATE OR REPLACE PROCEDURE yulin_sp (P_n1 IN NUMBER,P_n2 IN NUMBER, pv IN CHAR)

	IS

	BEGIN

	INSERT INTO yulin (v1,v2,v3,n1,n2)

	VALUES ('4',pv,'0',P_n1,P_n2);

	END;
3、執行Stored Procedures
	DECLARE

	BEGIN

	yulin_sp (5, 6, 'YT');

	COMMIT;

	END;
4、驗證是否寫入成功 select * from yulin
  









 其他指令 刪除資料:DELETE FROM yulin; 
刪除Procedures:DROP PROCEDURE yulin_sp;

沒有留言:

張貼留言