对于可能是基本问题,我提前道歉。我是学生,现在是关键时刻!
我正在使用 Oracle 10g Express。
我创建了一个函数:
create or replace FUNCTION test_glaccounts_description
(
account_description_param VARCHAR2
)
RETURN NUMBER
AS
description_dup_var NUMBER;
BEGIN
SELECT 1
INTO description_dup_var
FROM general_ledger_accounts
WHERE account_description = account_description_param;
RETURN description_dup_var;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN 0;
END;
并想在程序中使用该功能。我试过了:
PROCEDURE insert_gla_with_test
(
account_number_param NUMBER,
account_description_param VARCHAR2
)
AS
BEGIN
IF test_glaccounts_description = 1 THEN
INSERT INTO general_ledger_accounts
VALUES (account_number_param, account_description_param);
ELSE raise_application_error (-20001, 'Duplicate account description');
END IF;
END;
但它不喜欢“test_gla_accounts”行.....我做错了什么?据我了解,函数返回值1或0,在程序中,如果函数返回1,我希望将param字段添加到表中。如果函数返回 0,我希望该过程引发错误。