cancel
Showing results for 
Search instead for 
Did you mean: 

JDBC Lookup UDF- To fetch multiple values

Former Member
0 Kudos

Hi,

I have to fetch 3 values and populate it to the 3 fields in the target. The UDF am using is as attached. This UDF is for fetching one value. Kindly tell me about the changes I will have to make to fetch 3 values instead of 1 value.

String Query = " ";

Channel channel = null;

DataBaseAccessor accessor = null;

DataBaseResult resultSet = null;

// Query to retrieve the PROP value for the particular source value passed.

Query ="Select PROP from TANKS where ID='" + ID[0] + "' ";

try{

//Determine a channel, as created in the Configuration

channel = LookupService.getChannel("<Business Service>","<Communication Channel>");

//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("PROP"));

}

}

catch(Exception ex){

result.addValue(ex.getMessage());

}

finally{

try{

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

}

catch(Exception e){

result.addValue(e.getMessage());

}}

Edited by: SNIGDHA TRIVEDI on Oct 9, 2008 11:06 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

follow this post..

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

 Query ="Select PROP from TANKS where ID='" + ID[0] + "' ";

change this

Query ="Select PROP, Field2, Field3 from TANKS where ID='" + ID[0] + "' "

result.addValue((String)rowMap.get("PROP"));
result.addValue((String)rowMap.get("Field2"));
result.addValue((String)rowMap.get("Field3"));

Thanks

Gaurav

VijayKonam
Active Contributor
0 Kudos

> Query ="Select PROP from TANKS where ID='" + ID[0] + "' ";

>

Change this query to fetch your three values. Like PROP, Var1 and Var2.

> result.addValue((String)rowMap.get("PROP"));

Add statements here for Var1 and Var2 in to two local string variables.

Then manipulate them as you want to pass them to the target elements.

VJ