Aby zobaczyć dane w niektórych widokach w bazie danych, należy ustawić odpowiedni kontekst organizacji.
Jest to element funkcjonalności Muli-org.
R12
1) If you know the security_profile_id for that responsibility and user, you could call:
mo_global.set_org_access(null, <sp_id>, 'PA');
Security profiles are stored in PER_SECURITY_PROFILES, and the final parameter is the application short name of the application associated with the responsibility you would be using.
2) To set the operating unit context to a single operating unit, you could simply use:
mo_global.set_policy_context(‘S’,<org_id>);
However, it is generally preferable to use the following wrapper functions from MO_GLOBAL which will call the appropriate utilities to maintain the various elements of the multi-org context:
Procedure: SET_POLICY_CONTEXT(p_access_mode varchar2, p_org_id number)
This procedure will set the access mode, and when applicable the current operating unit context.
Procedure: SET_ORG_ACCESS(p_org_id_char varchar2, p_sp_id_char varchar2, p_appl_short_name varchar2)
This procedure determines if the application specified has multi-org access control enabled, by querying FND_MO_PRODUCT_INIT for the application short name. If this is enabled, and a security profile is specified (p_sp_id_char), then all orgs the user has access to will be populated in MO_GLOB_ORG_ACCESS_TMP. If there are more than one such org, the access method will be set to „Multiple”. Otherwise if no security profile id is specified, it will use the value of p_org_id to set the current operating unit value and set the access mode to „Single”.
Procedure: INIT(p_appl_short_name varchar2)
The procedure used by the applications when starting a new session. Based on the profile options „MO: Operating Unit” (ORG_ID) and „MO: Security Profile” (XLA_MO_SECURITY_PROFILE_LEVEL), this procedure calls set_org_access to establish the multi-org context for the session. To call this from withing SQL, the profile option context should have been initialized for the session.
Function: GET_CURRENT_ORG_ID
Returns the current operating unit setting. This should be null if the access mode is not 'S’
Function: GET_ACCESS_MODE
Returns the current access mode value.
11i
-- zmiana kontekstu organizacji --
BEGIN
apps.fnd_client_info.SET_ORG_CONTEXT('107');
END;
--ID organizacji można odczytać z:
SELECT * FROM hr_operating_units
SELECT * FROM org_organization_definitions
DECLARE
auser_name VARCHAR2(50) := 'LUSER';
aresponsibility_name VARCHAR2(150) := 'XX-Dystrybucja';
l_req_id NUMBER;
auser_id NUMBER;
aresponsibility_id NUMBER;
aapplication_id NUMBER;
BEGIN
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_LANGUAGE = POLISH';
SELECT user_id INTO auser_id FROM fnd_user WHERE user_name = auser_name;
SELECT responsibility_id, application_id
INTO aresponsibility_id, aapplication_id
FROM fnd_responsibility_tl
WHERE language = USERENV('lang')
AND UPPER(responsibility_name) LIKE UPPER(aresponsibility_name);
fnd_global.apps_initialize(auser_id, aresponsibility_id, aapplication_id);
BEGIN
INSERT INTO fnd_sessions VALUES (USERENV('sessionid'), TRUNC(SYSDATE));
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
COMMIT;
END; |
-- zmiana kontekstu organizacji --
begin
apps.fnd_client_info.SET_ORG_CONTEXT('107');
end;
--ID organizacji można odczytać z:
select * from hr_operating_units
select * from org_organization_definitions
declare
auser_name varchar2(50) := 'LUSER';
aresponsibility_name varchar2(150) := 'XX-Dystrybucja';
l_req_id number;
auser_id number;
aresponsibility_id number;
aapplication_id number;
begin
execute immediate 'ALTER SESSION SET NLS_LANGUAGE = POLISH';
select user_id into auser_id from fnd_user where user_name = auser_name;
select responsibility_id, application_id
into aresponsibility_id, aapplication_id
from fnd_responsibility_tl
where language = userenv('lang')
and upper(responsibility_name) like upper(aresponsibility_name);
fnd_global.apps_initialize(auser_id, aresponsibility_id, aapplication_id);
begin
insert into fnd_sessions values (userenv('sessionid'), trunc(sysdate));
exception
when others then
null;
end;
commit;
end;