How to read all columns of table as a result of lookUp

Hi,

I am not able to get all the column while using LookUp Component. I am getting only the no of column same as my search criteria.

Eg: I am having a table employee where i am having 4 columns (Name, ID, Dept, Address) and i want to lookup on the basis of name and get all the fields of related to name. I am getting only one field ID as my search result. My sql query is “select * from employee where name = ?”.

But when I am modifying my query as “select name,address,dept from employee where id = ?”, still only name and address is coming as result but not dept.

DataRecordMetadata metadata=new DataRecordMetadata("RecordMetadata0",DataRecordMetadata.DELIMITED_RECORD);
			metadata.addField(new DataFieldMetadata("name", DataFieldMetadata.STRING_FIELD,"\n"));
				
			// create lookup table. Will use previously created connection. The query string
			// is specified as a parameter
			// query string should contain ? (questionmark) in where clause
			// e.g. select * from customers where customer_id = ? and customer_city= ?
			String query = "select * from employee where name = ?;
			DBLookupTable lookupTable=new DBLookupTable("lookup",dbCon.getConnection(dbCon.getId()),metadata,query);
					
			// we initialize lookup table
			lookupTable.init();
	
			//creating data record for seeking
			DataRecordMetadata keyMetadata = lookupTable.getKeyMetadata();
			DataRecord keyRecord = new DataRecord(keyMetadata);
			keyRecord.init();
			RecordKey key = new RecordKey(keyMetadata.getFieldNamesArray(), keyMetadata);
			key.init();
			
			//create lookup query based on requested key
			Lookup lookup = lookupTable.createLookup(key, keyRecord);
			
			String[] keyValue = {"ABD"};
			for (int i = 0; i < keyValue.length; i++) {
				keyRecord.getField(i).fromString(keyValue[i]);
			}
			
			//try to lookup based on specified parameter
			lookup.seek(keyRecord);
	
			//display results, if there are any
			while(lookup.hasNext()){
				DataRecord value = lookup.next();
				//StringBuilder sValue = (StringBuilder)value.getField(0).getValue();
				//Object obj =  lookup.next();
				System.out.println(value);
			}

Please suggest some solution. Thanks in advance

Thanks
Pushpendra

Hello,
your lookup table metadata definition is wrong. The metadata describes record got from lookup table, that meeans, for query “select * from mytable” it should contain all the fields obtained from database.