I have a very strange problem regarding a section of my stored procedure giving inaccurate results.
The section of the code in question is:
Code:
case reprint_type
when 'J'
then
begin
select a.modified_by
into user_id
from adfapp.job_history a
where a.job_id = job_id
and a.state_name = 'Reprint'
and a.time_stamp = (select max(b.time_stamp) from adfapp.job_history b where b.job_id = job_id and b.state_name = 'Reprint')
with ur;
end;
For example, when this stored procedure is ran with a job_id of 513145, the value user_id is 'jackson'... which I know is the incorrect user id.
However, when I just run this simple select statement, I get the correct user id:
Code:
select a.modified_by
from adfapp.job_history a
where a.job_id = 513145
and a.state_name = 'Reprint'
and a.time_stamp = (select max(b.time_stamp) from adfapp.job_history b where b.job_id = 513145 and b.state_name = 'Reprint')
What could be the cause of this?
The entire stored proc is attached for reference...
Thanks for your help!