what is this query doing?
for(rset = conn.executeQ(OurQuery); rset.next(); items.put(rset.getString(1), rset.getString(2)));
rset = ResultSet
conn= Connection
Items --> private Hashtable items;
here is OurQuery
OurQuery = " \t \tselect LABEL_CODE ,NVL(INITCAP(DECODE(" + lang + ",1,DESC_EN_TX,DESC_AR_TX)),'N... AVAIL') " + "\t from FORM_USER_LABEL \t\t\t\t\t\t\t" + " \twhere UPPER(FORM_ID) \t\t= UPPER('" + v_frm + "')" + " \tAND USER_ID \t\t= " + v_user;
here is the executeQ method
public synchronized ResultSet executeQ(String s)
throws SQLException
{
Object obj = null;
ResultSet resultset = null;
try
{
if(conn.isClosed())
ConnectDB();
stmt = conn.createStatement();
resultset = stmt.executeQuery(s);
}
catch(Exception exception)
{
System.out.println(exception);
}
return resultset;
}
> Just make me understand this line of code...
>
>
> for(rset = conn.executeQ(OurQuery); rset.next();
> items.put(rset.getString(1), rset.getString(2)));
It's terrible.
I REFUSE to help you. Because among other problems the ResultSet is not being closed properly there.
This will lead to SERIOUS problems down the road in your project. It will run out of memory and crash.
So I cannot in good conscience help you. Sorry.
I can say only what the query does
First i will spit this query into an understandable manner.
1.select LABEL_CODE , // This selects the label code
2.NVL(INITCAP(DECODE(" + lang + ",1,DESC_EN_TX,DESC_AR_TX)),'N... AVAIL') // The above part of the query uses three functions one is NVL,INITCAP and Decode.
The NVL will convert when the query returns NULL to an user provided value i.e "N... AVAIL".
The InitCAP will convert the Starting letters of each word to Upper case
The Decode works like an if condition i.e
Decode(value,condition,if condition is true,if condition is false)
In your example, where decode works like
if(lang == 1)
DESC_EN_TX
else
DESC_AR_TX
and the remaining part of the query it converts to upper case and compares with a where condition.
if you still have doubts, first check for Decode option in oracle tutorial how it works then check the query.
it is not necessary to keep the "\t" inside the query