If I am running package from a scheduler job. How do I get the name of the job that is running me?
When I look at sys_context. I see BG_JOB_ID and FG_JOB_ID. I think BG_JOB_ID is for oracle like, SMON, but having a sys_context for that doesnt make sense. Do I use these?
Basically, I need to go to DBA_SCHEDULER_JOB_RUN_DETAILS and get the time that my last job ran. I use that in my package. I'd rather not add my own table to store this since it would be redundant. I don't want to hard code the job name, because that is denormalized and the job name could change and I forget to change my package. This would lead to a run time bug.
It can be done using metadata parameters.
You need to create program with parameters. Defined parameters will be metadata parameters.
Then you create job using program.
When Scheduler engine run job it fill up metadata arguments with relevant values and call you PL/SQL procedure. There you have all you needs.
There is link to DOC where available metadata agrguments are described