cancel
Showing results for 
Search instead for 
Did you mean: 

JDBC lookup returns null value

Former Member
0 Kudos

Hi all

I am performing simple jdbc lookup in PI 7.0.

For JDBC lookup i am follwing link

/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler

i am able to retrieve the values using the

following

..

.

Query = "SELECT EMP_NO FROM EMPLOYEE WHERE

EMP_NAME = 'abc' " ;

.

.

.

and display the values using

.

.

result.addValue("" + rowMap.get("EMP_NO"));

.

.

.

.

but when i am trying to get the max value of

EMP_NO using the following it is giving null

value ?

Query = "SELECT MAX(EMP_NO) FROM EMPLOYEE" ;

.

.

.

.

result.addValue("" + rowMap.get("EMP_NO"));

.

.

.

.

how to test whether the query has any value and

how to display the respective value?

kindly provide with a solution.

Regards

uday

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Try this

Query = "SELECT MAX(EMP_NO) Max_Emp_No FROM EMPLOYEE" ;

and after this :

.

.

.

.

Call as

+result.addValue("" + rowMap.get("Max_Emp_No"));+

Former Member
0 Kudos

Dear Antony

Thank u very much u solution of replacing emp_no with MAX(emp_no) while displaying using result set .addValue worked

i replaced :result.addValue(""+rowMap.get("EMP_NO" ));

with result.addValue(""+rowMap.get("MAX(EMP_NO)" )); it works

it gives u the max value of emp_no from the table

Once Again Thank u very much

Regards

Uday

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi all

As i said i am able to fetch the data from the database for the EMP_NO when the following combination is used for selection and display:

Query = "SELECT EMP_NO FROM EMPLOYEE WHERE EMP_NAME = 'abc' " ;

+result.addValue("" + rowMap.get("EMP_NO"));+

But when i am trying to fetch Max(EMP_NO) and display it using

Query = "SELECT MAX(EMP_NO) FROM EMPLOYEE" ;

and after executing i am using this code:

if (!resultSet.equals ( null ))

result.addValue("true0");

and it returns value true0

means there is some value in result

but when i am trying to display it using same

+result.addValue("" + rowMap.get("EMP_NO"));+

it is displaying "null"

meaning problem in displaying it .

Am i getting it properly?

HI Arpil

tried ur solution

but it is giving exception.

can anyone plz help me and provide me with a solution

Regards

uday

Former Member
0 Kudos

In the blog, the code is:

for(Iterator rows = resultSet.getRows();rows.hasNext();){

Map rowMap = (Map)rows.next();

result.addValue((String)rowMap.get("URole"));

Maybe try with this...

for(Iterator rows = resultSet.getRows();rows.hasNext();){

Map rowMap = (Map)rows;

result.addValue((String)rowMap.get("URole"));

Regards

dharamveer_gaur2
Active Contributor
0 Kudos

Your Field name EMP_NO same as database field name?

dharamveer_gaur2
Active Contributor
0 Kudos

Hi

Try typecasting this

result.addValue("" + rowMap.get("EMP_NO"));

as result.addValue("" + (String) rowMap.get("EMP_NO")); to add result list.

Former Member
0 Kudos

HI veer

This solution did not work still it returns null value .

to check whether after query is executed whether result cantains any value i tried this

...

...

resultSet = accessor.execute(Query);

if (!resultSet.equals ( null ))

result.addValue("true0");

..

it returns me 'true0" in display queue but later when it executes this statement

......

result.addValue("" + rowMap.get("EMP_NO"));

.......

it gives null value what could be the problem ?

Regards

uday

dharamveer_gaur2
Active Contributor
0 Kudos

Check EMP_NO field type.Check same Sql query from database,

Former Member
0 Kudos

Hi

I have executed the same query in sql editor it works fine and returns the correspongding value.

Data type of EMP_NO is NUMBER of length 5.

Regards

uday