下面列出的代碼創建了一個只有規範的包。我不斷收到錯誤。僅用規格創建包?
錯誤:
Error: PL/SQL: Compilation unit analysis terminated
Error(1,14): PLS-00201: identifier 'TAXRATE_PKG' must be declared
Error(1,14): PLS-00304: cannot compile body of 'TAXRATE_PKG' without its specification
代碼:
CREATE OR REPLACE PACKAGE BODY TAXRATE_PKG IS
PROCEDURE state_tax_pf(
p_state IN VARCHAR2,
pv_tax_nc OUT NUMBER,
pv_tax_tx OUT NUMBER,
pv_tax_tn OUT NUMBER)
IS
lv_state NUMBER;
BEGIN
IF p_state = 'NC' THEN
pv_tax_nc := 0.35;
ELSIF p_state = 'TX' THEN
Pv_tax_tx := 0.05;
ELSIF p_state = 'TN' THEN
pv_tax_tn := 0.02;
END IF;
RETURN lv_state;
END;
END;
您需要先創建包。 'CREATE OR REPLACE PACKAGE TAXRATE_PKG IS PROCEDURE state_tax_pf(p_state IN VARCHAR2,pv_tax_nc OUT NUMBER,pv_tax_tx OUT NUMBER,pv_tax_tn OUT NUMBER); END TAXRATE_PKG;'或'CREATE OR REPLACE PACKAGE TAXRATE_PKG is FUNCTION get_state_tax(p_state IN VARCHAR2)RETURN NUMBER; END TAXRATE_PKG;'適當。 (未測試過,沒有Oracle DB方便,可能有其他語法錯誤 –
@ShannonSeverance我將創建一個只包含一個規範的包 – user3508766
從你的create語句中刪除'body','create package BODY'創建而不是規範 –