cancel
Showing results for 
Search instead for 
Did you mean: 

JDBC lookup... ((String)rowMap.get(""))

former_member187587
Contributor
0 Kudos

Hey all,

I'm using the JDBC lookup API but getting only nulls.

Query runs fine from SQL standard enviorment.

How does the rowMap.get() method functions?

How does it extract the requesetd data?

Pelase share from your experiance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If possible can you paste your lookup code here, then only we can say where you did mistake or missed something.

Thanks

Farooq

VijayKonam
Active Contributor
0 Kudos

Check the help here for the lookup API clss u r using..

http://help.sap.com/javadocs/pi/SP3/xpi/index.html

VJ

former_member187587
Contributor
0 Kudos

Hey all,

Problem solved.

Two failure points:

1. I have changed the casting action ((String)rowMap.get("BLA_BLA_CULOMN")) to the method toString(). got the value from the Database correctly.

2.moved on to the "real thing" to take the Sequence generated by the Oracle DB. query I was used was wrong,fixed that as well.

works like magic....

thank you all.

(gave each of you 2p, got myself a cup of coffee...)

Edited by: Nimrod Gisis on Sep 3, 2008 4:31 PM

Answers (1)

Answers (1)

hemant_chahal
Contributor
0 Kudos

Hello

Abstract mapRow(ResultSet, int) method converts each row of the JDBC ResultSet into an object.

thanks

hemant

former_member187587
Contributor
0 Kudos

Thanks Hemant,

what is the input parameters required for the get() method? Column name?

I understand the method returns and object that can be cast into string, correct?

this is strange as I'm getting null even for query that return for sure a single value...

.....

This is my source:

//write your code here

String Query = "";

Channel channel = null;

DataBaseAccessor accessor = null;

DataBaseResult resultSet = null;

// Build the Query String

Query = "SELECT SEQ_EDI_EXTRACT_ID.NEXTVAL FROM DUAL";

//QuerySingle="SELECT EDI_EXTRACT_ID FROM TW,EDI_EXTRACT WHERE EDI_EXTRACT_ID=5079815"

try{

//Determine a channel, as created in the Configuration

channel = LookupService.getChannel("sys_DEV0","JDBC_Lookup");

//Get a system accessor for the channel. As the call is being made to an DB, an DatabaseAccessor is obtained.

accessor = LookupService.getDataBaseAccessor(channel);

//Execute Query and get the values in resultset

resultSet = accessor.execute(Query);

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

{

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

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

}

}

catch(Exception ex){

result.addValue(ex.getMessage());

}

finally{

try{

if (accessor!=null) accessor.close();

}

catch(Exception e){

result.addValue(e.getMessage());

}

}

Edited by: Nimrod Gisis on Sep 3, 2008 8:44 AM