To fetch data from views and to get the same for the required Organization ID, we need to set the org_id in the SQL Developer.
For SQL Developer:
BEGIN
MO_GLOBAL.SET_POLICY_CONTEXT('S', <org_id>);
END;
For SQL*PLUS:
SQL> exec mo_global.init('SQLAP'); exec mo_global.set_policy_context('S','&org_id');
For sqlplus to have same org context as given responsibility :
DECLARE
l_resp_id NUMBER;
l_user_id NUMBER;
l_security_profile_id NUMBER;
l_org_id NUMBER;
BEGIN
SELECT user_id INTO l_user_id FROM fnd_user WHERE user_name LIKE '&USER_NAME';
SELECT responsibility_id
INTO l_resp_id
FROM FND_RESPONSIBILITY_VL
WHERE responsibility_name LIKE '&responsibility_name';
FND_GLOBAL.APPS_INITIALIZE(l_user_id, l_resp_id, <Application ID>);
MO_GLOBAL.INIT('SQLAP');
END;
For SQL Developer:
BEGIN
MO_GLOBAL.SET_POLICY_CONTEXT('S', <org_id>);
END;
For SQL*PLUS:
SQL> exec mo_global.init('SQLAP'); exec mo_global.set_policy_context('S','&org_id');
For sqlplus to have same org context as given responsibility :
DECLARE
l_resp_id NUMBER;
l_user_id NUMBER;
l_security_profile_id NUMBER;
l_org_id NUMBER;
BEGIN
SELECT user_id INTO l_user_id FROM fnd_user WHERE user_name LIKE '&USER_NAME';
SELECT responsibility_id
INTO l_resp_id
FROM FND_RESPONSIBILITY_VL
WHERE responsibility_name LIKE '&responsibility_name';
FND_GLOBAL.APPS_INITIALIZE(l_user_id, l_resp_id, <Application ID>);
MO_GLOBAL.INIT('SQLAP');
END;