Les escribo por lo siguiente, tengo un problema con un desarrollo en una instancia Oracle R12, tengo todo el codigo en un trigger y veo que me obtiene la info necesaria para setear con la siguiente instruccion Fnd_Global.Apps_Initialize, pero siempre me genera un error al tratar de inicializar y por consiguiente, no me deja lanzar el Fnd_Request.Submit_Request.
Adjunto codigo del trigger, Funcion de Seteo y error q almaceno en una tabla.
Error:
Código SQL:
Ver original
ORA-20001: Error de Oracle -20001: Se detectó ORA-20001: Error de Oracle -4092: Se detectó ORA-04092: no se puede SET NLS en un disparador en fnd_global.set_nls.set_parameter('NLS_LANGUAGE','LATIN AMERICAN SPANISH'). en fnd_global.set_nls.
--Codigo del Trigger
Código SQL:
Ver original
CREATE OR REPLACE TRIGGER Xxcoo_Ap_Lanza_Concurrente After UPDATE ON FND_CONCURRENT_REQUESTS REFERENCING NEW AS NEW OLD AS OLD FOR Each ROW WHEN ((NEW.Phase_Code = 'C') AND (NEW.Status_Code = 'C') AND (NEW.Program_Application_Id = 673) AND (NEW.Concurrent_Program_Id = 52355)) DECLARE v_Org_Id NUMBER; Nrequest_Id NUMBER; v_Resp_Id NUMBER; v_User_Name Varchar2(50); v_Responsability Varchar2(200); v_Context Varchar2(100); v_Context2 Varchar2(500); l_Boolean BOOLEAN; BEGIN SELECT Requestor, Responsibility_Id INTO v_User_Name, v_Resp_Id FROM Fnd_Conc_Req_Summary_v WHERE Request_Id = :NEW.Request_Id ORDER BY Request_Id DESC; SELECT Responsibility_Name INTO v_Responsability FROM Fnd_Responsibility_Vl WHERE Responsibility_Id = v_Resp_Id; SELECT To_Number(Substr(v.Profile_Option_Value, 1, 30)) INTO v_Org_Id FROM Applsys.Fnd_Profile_Options p, Applsys.Fnd_Profile_Option_Values v, Applsys.Fnd_Responsibility Rsp, Hr.Hr_All_Organization_Units o, Applsys.Fnd_Responsibility_Tl r WHERE p.Profile_Option_Id = v.Profile_Option_Id(+) AND Rsp.Application_Id(+) = v.Level_Value_Application_Id AND Rsp.Responsibility_Id(+) = v.Level_Value AND Rsp.Responsibility_Id = r.Responsibility_Id AND r.Responsibility_Name LIKE v_Responsability --'Coomeva AP Superuser Colombia' AND r.LANGUAGE = 'ESA' AND p.Profile_Option_Name = 'ORG_ID' AND To_Char(o.Organization_Id) = Substr(v.Profile_Option_Value, 1, 30); -- Setting the context ---- v_Context := Xxcoo_Ap_Utilitiescheq_Co_Pkg.Set_Context(v_User_Name, v_Responsability, v_Org_Id); --v_Context := Set_Context('&V_USER_NAME', '&V_RESPONSIBILITY', 82); v_Context2 := 'v_User_Name: ' || v_User_Name || ', v_Responsability: ' || v_Responsability || ', v_Org_Id: ' || v_Org_Id || ', v_Context: ' || v_Context; IF v_Context = 'F' THEN Dbms_Output.Put_Line('Error while setting the context'); END IF; l_Boolean := Fnd_Request.Set_Mode(TRUE); Nrequest_Id := Fnd_Request.Submit_Request(Application => 'XXCOO', Program => 'XXCOOAPMOVTEF2', Start_Time => Sysdate, Sub_Request => FALSE, Argument1 => :NEW.Request_Id); --Commit; -- End If; INSERT INTO Cvj_Prueba_Trigger (Request_Id_Eft, Request_Id_Mov, Fecha, Variables_Contex) VALUES (:NEW.Request_Id, Nrequest_Id, Sysdate, v_Context2); --Commit; END;
-- Funcion Set_Context
Código SQL:
Ver original
FUNCTION Set_Context(i_User_Name IN Varchar2, i_Resp_Name IN Varchar2, i_Org_Id IN NUMBER) RETURN Varchar2 IS v_User_Id NUMBER; v_Resp_Id NUMBER; v_Resp_Appl_Id NUMBER; v_Lang Varchar2(100); v_Session_Lang Varchar2(100) := Fnd_Global.Current_Language; v_Return Varchar2(10) := 'T'; v_Nls_Lang Varchar2(100); v_Org_Id NUMBER := i_Org_Id; v_Mensaje Varchar2(4000) := NULL; /* Cursor to get the user id information based on the input user name */ Cursor Cur_User IS SELECT User_Id FROM Fnd_User WHERE User_Name = i_User_Name; /* Cursor to get the responsibility information */ Cursor Cur_Resp IS SELECT Responsibility_Id, Application_Id, LANGUAGE FROM Fnd_Responsibility_Tl WHERE Responsibility_Name = i_Resp_Name AND LANGUAGE = 'ESA'; /* Cursor to get the nls language information for setting the language context */ Cursor Cur_Lang(p_Lang_Code Varchar2) IS SELECT Nls_Language FROM Fnd_Languages WHERE Language_Code = p_Lang_Code; BEGIN /* To get the user id details */ OPEN Cur_User; Fetch Cur_User INTO v_User_Id; IF Cur_User%Notfound THEN v_Mensaje := Sqlerrm; INSERT INTO Cvj_Prueba_Trigger (Request_Id_Eft, Request_Id_Mov, Fecha, Variables_Contex) VALUES (0, 0, Sysdate, 'Error en el usuario: ' || i_User_Name || '. Problema: ' || v_Mensaje); v_Return := 'F'; END IF; --IF cur_user%NOTFOUND Close Cur_User; /* To get the responsibility and responsibility application id */ OPEN Cur_Resp; Fetch Cur_Resp INTO v_Resp_Id, v_Resp_Appl_Id, v_Lang; IF Cur_Resp%Notfound THEN v_Mensaje := Sqlerrm; INSERT INTO Cvj_Prueba_Trigger (Request_Id_Eft, Request_Id_Mov, Fecha, Variables_Contex) VALUES (0, 0, Sysdate, 'Error en la responsabilidad: ' || i_Resp_Name || '. Problema: ' || v_Mensaje); v_Return := 'F'; END IF; --IF cur_resp%NOTFOUND Close Cur_Resp; /* Setting the oracle applications context for the particular session */ Fnd_Global.Apps_Initialize(User_Id => v_User_Id, Resp_Id => v_Resp_Id, Resp_Appl_Id => v_Resp_Appl_Id); /* Setting the org context for the particular session */ Mo_Global.Set_Policy_Context('S', v_Org_Id); /* \* setting the nls context for the particular session *\ If v_Session_Lang != v_Lang Then Open Cur_Lang(v_Lang); Fetch Cur_Lang Into v_Nls_Lang; Close Cur_Lang; Fnd_Global.Set_Nls_Context(v_Nls_Lang); End If; --IF v_session_lang != v_lang*/ Commit; RETURN v_Return; Exception WHEN Others THEN v_Mensaje := Sqlerrm; INSERT INTO Cvj_Prueba_Trigger (Request_Id_Eft, Request_Id_Mov, Fecha, Variables_Contex) VALUES (0, 0, Sysdate, v_Mensaje); RETURN 'F'; END Set_Context;
Si alguien sabe que puedo hacer para solucionar el error se lo agradeceria, la verdad se necesita esto lo mas pronto posible para poder llevarlo a la instancia de producción.
Muchas gracias.
Scooby.