Friday, September 18, 2009

List Active Users and Their Active Responsibilities In Oracle Apps

select user_name, application_name, responsibility_name,
security_group_name,
greatest(to_date(u.start_date), to_date(ur.start_date), to_date(r.start_date)) start_date,
decode(
least(nvl(u.end_date, to_date('01/01/4712','DD/MM/YYYY')),
nvl(ur.end_date, to_date('01/01/4712','DD/MM/YYYY')),
nvl(r.end_date, to_date('01/01/4712','DD/MM/YYYY'))),
to_date('01/01/4712','DD/MM/YYYY'), '',
least(nvl(u.end_date, nvl(ur.end_date, r.end_date)),
nvl(ur.end_date, nvl(u.end_date, r.end_date)),
nvl(r.end_date, nvl(u.end_date, ur.end_date)))) end_date
from fnd_user u, fnd_user_resp_groups_all ur,
fnd_responsibility_vl r, fnd_application_vl a,
fnd_security_groups_vl s
where a.application_id = r.application_id
and u.user_id = ur.user_id
and r.application_id = ur.responsibility_application_id
and r.responsibility_id = ur.responsibility_id
and ur.start_date <= sysdate
and nvl(ur.end_date, sysdate + 1) > sysdate
and u.start_date <= sysdate
and nvl(u.end_date, sysdate + 1) > sysdate
and r.start_date <= sysdate
and nvl(r.end_date, sysdate + 1) > sysdate
and ur.security_group_id = s.security_group_id
and r.version in ('4','W','M')
--and responsibility_name = 'Functional Administrator'
order by user_name, application_name, responsibility_name,
security_group_name

Thursday, September 3, 2009

Code to print webbean's child names with their ids

Enumeration enum= webBean.getChildNames();
while(enum!=null && enum.hasMoreElements())
{
String name = (String)enum.nextElement();
System.out.println(name);
}

it should print the child names, with their ids

Monday, July 27, 2009

Puzzle - $1 vanished ?

Three men go to a cheap motel, and the desk clerk charges them a sum of $30.00 for the night. The three of them split the cost ten dollars each. Later the manager comes over and tells the desk clerk that he overcharged the men, since the actual cost should have been $25.00. The manager gives the bellboy $5.00 and tells him to give it to the men. The bellboy, however, decides to cheat the men and pockets $2.00, giving each of the men only one dollar.
Now each man has paid $9.00 to stay for the night, and 3 x $9.00 = $27.00. The bellboy has pocketed $2.00. But $27.00 + $2.00 = $29.00. Where is the missing $1.00? WTF?


Solution:
Total Customer effectively paid =27
Total amnt the hotel got = 25
The difference is in bellboy's pocket = 27-25 =2

Puzzle -Daughter's Age Problem

A census taker came to a house where a man lived with
three daughters. "What are your daughters' ages?" he asked.
The man replied, "The product of their ages is 72, and the
sum of their ages is my house number."
"But that's not enough information," the census taker insisted.
"All right," answered the farmer, "the oldest loves chocolate.

What are the daughters' ages?

Solution :

We can look at all the possibilities this way - the oldest may be the same age as the middle, and the middle may be the same age as the youngest:
OLD MID YOUNG SUM
72 1 1 74
36 2 1 39
24 3 1 28
18 4 1 23
18 2 2 22
12 3 2 17
12 6 1 19
9 8 1 18
9 4 2 15
8 3 3 14
6 6 2 14
6 4 3 13
These are all the possibilities, since if we give the oldest a lower age, there is no way the product can equal 72.We know their ages add up to the farmer's house number. The sum column gives all possibilities for the house number. When the farmer gave the census person the information about the product of their ages being 72 and the sum of their ages being his house number the census person said this was not enough information. So there must have been at least two different possibilities that were still viable options for the census taker to choose from. This means the house number must have had two sums equal it. So the daughters are:
8 3 3 14
6 6 2 14
since they both add up to 14, the only number that appeared twice in the sum of the ages. The fact that the farmer had an oldest daughter says that the daughters must in fact be ages 8, 3, and 3.

Test For Palindrome - Java

package palindrome;
import java.util.*;

public class TestPalindrome
{
public TestPalindrome()
{
}

public static boolean isPalindrome(String word) {
int left = 0; // index of leftmost unchecked char
int right = word.length() -1; // index of the rightmost

while (left < right) { // continue until they reach center
if (word.charAt(left) != word.charAt(right)) {
return false; // if chars are different, finished
}
left++; // move left index toward the center
right--; // move right index toward the center
}
return true; // if finished, all chars were same
}

public static void main(String[] args)
{
TestPalindrome testPalindrome = new TestPalindrome();
String s = "Was it a rat I saw?" ;
s = s.replaceAll("[\\s\\p{Punct}]", "").toLowerCase();
boolean flag = isPalindrome(s);
System.out.println(s + " PALINDROME ? " + flag);

}

}

Wednesday, July 1, 2009

Extract Jar from Blob Column through Java code

I used this code to extract jar file which was stored in BLOB column of the database.
/**
*
* This code extracts jar file from cz_archives table from the BLOB column.
*
*/

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class ExtractBlob
{
public ExtractBlob()
{
}
final static int bBufLen = 4 * 8192;
static String query;
static String outFile;
static Connection conn;

public static void main(String[] args) throws FileNotFoundException, IOException, SQLException
{
String baseFolder = "C:/CZArchives";
String folderName = "";
String fileName = "";

String query = "SELECT 'TEST-Archive' FOLDER_NAME, "
+ "CZArch.ARCHIVE_URL DOCNAME,CZArch.ARCHIVE_BLOB "
+ "FROM CZ_ARCHIVES CZArch, CZ_RP_ENTRIES CZRp "
+ "WHERE CZRp.OBJECT_ID = CZArch.ARCHIVE_ID "
+ "AND CZArch.deleted_flag = '0' "
+ " AND CZRp.OBJECT_TYPE = 'ARC' "
+ "and CZArch.name = 'nameofyourjarfile' ";
//replace nameofyourjarfile with your jar file name

conn = getConnection();
conn.setAutoCommit(false);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
Blob blob = null;
while (rs.next())
{
folderName = rs.getString(1);
fileName = rs.getString(2);
// String created = rs.getString(4);
// String updated = rs.getString(5);
blob = rs.getBlob(3);
System.out.println("Got " + folderName);
System.out.println("Got " + fileName);
// System.out.println("Created " + created);
// System.out.println("Updated " + updated);

outFile = baseFolder + "/" + folderName;

outFile = baseFolder;
long wrote = 0;
File file = new File(outFile);
file.mkdir();
outFile = outFile + "/" + fileName;

OutputStream fwriter = new FileOutputStream(outFile);
wrote = readFromBlob(blob, fwriter);
fwriter.close();
System.out.println("Wrote " + wrote + " bytes to file " + outFile);
}
rs.close();
stmt.close();
conn.close();
}

public static Connection getConnection()
{
Connection con = null;

String dsn = "::";
String uname = "apps";
String passwd = "pwd";
try
{
String driver = "oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@" + dsn;
Class.forName(driver);
con = DriverManager.getConnection(url, uname, passwd);
}
catch (Exception ee)
{
ee.printStackTrace();
}

return con;
}

public static long readFromBlob(Blob blob, OutputStream out) throws SQLException, IOException
{
InputStream in = blob.getBinaryStream();


int length = -1;
long read = 0;
byte[] buf = new byte[bBufLen];
while ((length = in.read(buf)) != -1)
{
out.write(buf, 0, length);
read += length;
}
in.close();
return read;
}

}

Thursday, June 25, 2009

How to find the correct version of JDeveloper to use with eBusiness Suite 11i or Release 12.x

Identify the OA Framework version in your instance by activating diagnostics and click the "About This Page" from any OAF page. Click the "Technology Components" tab. The OA Framework version in the top row of the table can then be matched to the JDeveloper Patch.

Release 11i
OA Framework 5.10 patch JDeveloper 9i Patch
ATG.PF.H(patch 3438354 or OApps 11.5.10) Patch 4045639 9IJDEVELOPER WITH OA EXTENSION ARU FOR FWK.H
ATG PF CU1 (patch 4017300) Patch 4141787 9IJDEVELOPER WITH OA EXTENSION ARU FOR CU1
ATG PF CU2 (patch 4125550) Patch 4573517 Oracle9i JDeveloper with OA Extension for 11.5.10 CU2
11i.ATG_PF.H RUP3 (patch 4334965) Patch 4725670 9IJDEVELOPER WITH OA EXTENSION ARU FOR 11i10 RUP3
11i.ATG_PF.H RUP4 (patch 4676589) Patch 5455514 9IJDEVELOPER WITH OA EXTENSION ARU FOR 11i10 RUP4
11i.ATG_PF.H RUP5 (patch 5473858) Patch 6012619 9IJDeveloper With OA Extension ARU FOR 11i10 RUP5
11i.ATG_PF.H.RUP6 (patch 5903765) Patch 6739235 9IJDeveloper With OA Extension ARU FOR 11i10 RUP6


Release 12.0
ATG Release 12 Version JDeveloper 10g Patch
12.0.0 Patch 5856648 10g Jdev with OA Extension

12.0.1(patch 5907545) Patch 5856648 10g Jdev with OA Extension

12.0.2(patch 5484000 or 5917344) Patch 6491398 10g Jdev with OA Extension ARU for R12 RUP2 (replaces 6197418)
12.0.3(patch 6141000 or 6077669) Patch 6509325 10g Jdev with OA Extension ARU for R12 RUP3
12.0.4(patch 6435000 or 6272680) Patch 6908968 10G JDEVELOPER WITH OA EXTENSION ARU FOR R12 RUP4
12.0.5(No new ATG code released) No new JDev patch required
12.0.6(patch 6728000 or patch 7237006) Patch 7523554 10G Jdeveloper With OA Extension ARU for R12 RUP6

refer to metalink, doc id : 416708.1