create or replace
FUNCTION F_GET_ACC_ID
RETURN number
IS
PRAGMA AUTONOMOUS_TRANSACTION; --声明自主事务处理。
v_cur_idx number;
v_ret_val number;
v_max_val number;
BEGIN
BEGIN
SELECT IDX
INTO v_cur_idx
FROM COM_ID_TABLE
WHERE CATEGORY_NAME='ACCSEQ';
v_max_val:=65535;
EXCEPTION
WHEN NO_DATA_FOUND THEN
rollback;
RETURN null;
WHEN OTHERS THEN
rollback;
RETURN null;
END;
IF v_cur_idx < v_max_val THEN
v_ret_val := v_cur_idx+1;
UPDATE COM_ID_TABLE
SET IDX = v_ret_val
WHERE category_name = 'ACCSEQ';
ELSE
UPDATE COM_ID_TABLE
SET IDX = 4096
WHERE category_name = 'ACCSEQ';
v_ret_val := 4096;
END IF;
commit;
RETURN v_ret_val;
END F_GET_ACC_ID;
FUNCTION F_GET_ACC_ID
RETURN number
IS
PRAGMA AUTONOMOUS_TRANSACTION; --声明自主事务处理。
v_cur_idx number;
v_ret_val number;
v_max_val number;
BEGIN
BEGIN
SELECT IDX
INTO v_cur_idx
FROM COM_ID_TABLE
WHERE CATEGORY_NAME='ACCSEQ';
v_max_val:=65535;
EXCEPTION
WHEN NO_DATA_FOUND THEN
rollback;
RETURN null;
WHEN OTHERS THEN
rollback;
RETURN null;
END;
IF v_cur_idx < v_max_val THEN
v_ret_val := v_cur_idx+1;
UPDATE COM_ID_TABLE
SET IDX = v_ret_val
WHERE category_name = 'ACCSEQ';
ELSE
UPDATE COM_ID_TABLE
SET IDX = 4096
WHERE category_name = 'ACCSEQ';
v_ret_val := 4096;
END IF;
commit;
RETURN v_ret_val;
END F_GET_ACC_ID;