Skip to content
Advertisement

PL/SQL: Function returned without value

I wrote below FUNCTION to check given data is exist.

CREATE OR REPLACE FUNCTION PSPIWEB_USER.AB_GetAuditTypeID (in_DeptID NUMBER)
   RETURN NUMBER
IS
   intAuditTypeID   NUMBER;
BEGIN

   SELECT audittypeid
     INTO intAuditTypeID
     FROM iqa_department
    WHERE seqno = in_deptid;

   RETURN intAuditTypeID;
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      NULL;
   WHEN OTHERS
   THEN
      RAISE;
END;
/

It is working before but when i add new data on table named iqa_department it suddenly after triggering the function returns me with that error, im kinda new in oracle fom mysql to oracle

Here’s how i call it.

Select IQA_CAR.CAR_NO,IQA_CAR.REFNO,NVL(null,' '),NVL(IQA_CAR.BFGSECTION ,' ') ,IQA_CAR.ERR_PROOF,NVL(IQA_SECTION.SECTIONNAME,' '),NVL (To_char(iqa_car.auditdate,'YYYY-MM-DD'), ' '),NVL(IQA_CAR.ISSUEDTO,' '),NVL(TQM_VWEMPLOYEE.NAME,' '), NVL (To_Char(iqa_car.issueddate,'YYYY-MM-DD'), ' '),NVL (To_Char(iqa_car.closeddate,'YYYY-MM-DD'), 'N'),NVL(VW_CURR_APPROVER.current_approver,' ') from IQA_CAR 
                   left outer join IQA_SECTION 
                    on IQA_SECTION.SECTIONID = IQA_CAR.AREAID 
                    left outer join TQM_VWEMPLOYEE 
                    on TQM_VWEMPLOYEE.EMP_NUMBER = IQA_CAR.ISSUEDTO 
                    full outer join VW_CURR_APPROVER 
                    on VW_CURR_APPROVER.car_no = IQA_CAR.CAR_NO 
                    where ab_getaudittypeid(deptid) = 11

error i’m getting

ORA-06503: PL/SQL: Function returned without value
ORA-06512: at "PSPIWEB_USER.AB_GETAUDITTYPEID", line 19

Advertisement

Answer

try this:

CREATE OR REPLACE FUNCTION PSPIWEB_USER.AB_GetAuditTypeID (in_DeptID NUMBER)
   RETURN NUMBER
IS
   intAuditTypeID   NUMBER;
BEGIN

   SELECT audittypeid
     INTO intAuditTypeID
     FROM iqa_department
    WHERE seqno = in_deptid;

   RETURN intAuditTypeID;
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      RETURN NULL;
   WHEN OTHERS
   THEN
      RAISE;
END;
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement