在存儲過程當中使用select into賦值的時候,假如無數據的話,會拋出ORA-01403異常,解決辦法以下:
BEGIN SELECT ROUND(TO_NUMBER(T.SINGLE_SOURCE_AMOUNT) / TO_NUMBER(T.TOTAL_AMOUNT), 2) * 100 INTO VAR_SINGLE_AMOUNT_PER FROM CS_PURCHASE_AMOUNT_YEAR T WHERE TO_NUMBER(T.TOTAL_AMOUNT) != 0 AND T.TOTAL_AMOUNT IS NOT NULL AND T.CREATE_YEAR = VAR_LAST_YEAR AND T.SUPPLIER_CODE = VAR_SUPPLIER_CODE; EXCEPTION WHEN NO_DATA_FOUND THEN VAR_SINGLE_AMOUNT_PER := 0; END;