Skip to main content

Hi,

I’m trying to raise an error to a Background Job.

I have a procedure that is called by a background job.

I’ll fetch an object, and sometime it doesn’t exist. Normally because the object is deleted by the user before the job has been run.

    CURSOR get_Objid IS
      select objid from project_transaction WHERE objkey = 'BB8A4E9B030B41DDABB62F8381C9DFFD';

    OPEN get_Objid;
    FETCH get_Objid
      INTO objid_;
    CLOSE get_Objid;

 

I would then like to handle the exception and have a custom error message send back to the background job. So I use this one:

    IF (objid_ is null) THEN
        raise_application_error(-20001,'No value in objid!');
    END IF;

It works find when running the script in a terminal, but if I run it with a background job I don’t get the error.

How can this be done?

BR Kresten

Hi @krestensb 

Maybe objid_ is not null after all. What error do you get if you do this

 IF (objid_ is null) THEN
raise_application_error(-20001,'No value in objid!');

else
raise_application_error(-20001,objid_);
END IF;

 

 


Hi @krestensb 

Maybe objid_ is not null after all. What error do you get if you do this

 IF (objid_ is null) THEN
raise_application_error(-20001,'No value in objid!');

else
raise_application_error(-20001,objid_);
END IF;

 

 

I also think this should work fine.

One tip regarding exception handling with IFS coding is that it’s always good to use Error_Sys package instead of raise_application_error unless you need to handle the error number by yourself.

It will give a readable error message in the background job :wink:

Error text with raise_application_error

Error text with Error_Sys

begin
 Error_sys.Appl_General('YourLuName', 'NOVALUE: No value!');
end;

Cheers!

Damith