then you actually need to make is a global variable in the specification of pkg2 - not the body.
right now, I have no clue where you defined it - but if it was like this:
create or replace package pkg2
as
g_merge_variable number;
procedure p;
end;
/
> create or replace package body pkg2
2 as
3 procedure p
4 is
5 begin
6 MERGE INTO TABLE A.... g_merge_variable;
end;
8 end;
9 /
then you can access pkg2.g_merge_variable anywhere you want.
IF it isn't like that, then you cannot - plain and simple, you'll have to figure out something else - like changing the code generator to generate code that actually meets your requirement.