Sunday, 15 May 2011

Using PL/SQL to generate Apps Initialize command



You don't need to enter the instance anymore to extract Apps Initialize command.

Just run the following code . Replace USERNAME_HERE by your username

declare
l_user_id fnd_user.
user_id%type;
l_responsibility_id fnd_responsibility_tl.responsibility_id
%type;
l_application_id fnd_responsibility_tl.application_id
%type;
begin
select t.user_id
into l_user_id
from fnd_user t
where t.user_name = 'USERNAME_HERE';
select t.responsibility_id, t.application_id
into l_responsibility_id, l_application_id
from fnd_responsibility_tl t
where t.responsibility_name like 'RESPONSIBILITY_NAME_HERE' and
t.language
= 'US';
fnd_global.apps_initialize(l_user_id,
l_responsibility_id,
l_application_id);
dbms_output.put_line(
'begin fnd_global.apps_initialize' ||
' (user_id => ' || l_user_id || ', resp_id => ' ||
l_responsibility_id
|| ', resp_appl_id => ' ||
l_application_id
|| '); end;');
end;

JDBC and LC_ALL variable

  I was visiting recently one of our customer’s site . Customer complaint about one module which didn’t work for him. Finally I found that the problem is with the following piece of code

PreparedStatement  stmt = _dbConn.prepareStatement(“select decode(attr,‘ATTRIBUTE1’,’COLUMN’,null) from xx_entities”);
 stmt.setString(1, packageName);
 stmt.setInt(2, packageLineNum);
 rs= (ResultSet)stmt.executeQuery();
 StringBuffer result= new StringBuffer();
 result.append("<parameters>");
 while (rs.next())
        result.append("<argument><name>"+rs.getString("param_name")+"</name><value>"+rs.getString("column_value")+"</value></argument>");
 result.append("</parameters>");
        return result.toString();

  The funny part what SQL statement was running just fine from any SQL client and retuned good result, but when running from java the ResultSet object was always empty!! I always got "<parameters></parameters>”


After straggling for several hours, one of my colleagues found the solution. He told me "Hei, check the LC_ALL variable” , and so I did. The value was “ru_RU.cp1251”. As soon as I changed it to “en-US” it worked immediately.