cancel
Showing results for 
Search instead for 
Did you mean: 

JDBC Lookup Returns Multiple Rows

0 Kudos

Hi Experts

I have a scenario where I have to lookup the "company name" for a user from a JDBC table. A user may have multiple companies associated. There is another column "Last Updated Date" so I need to pick the company with the latest LastUpdatedDate.

The table looks like

User CompanyName LastUpdateDate

A CompanyA Date1

A CompanyB Date2

B CompanyC Date1

D CompanyB Date3

So while looking up is it possible to send a query something like "order by

LastUpdatedDate" and then pick the first record?

Or

Would have to write a udf to fetch all the records?

Or

can it be done without a udf?

Kindly assist.

Regards

Sonal

Accepted Solutions (0)

Answers (1)

Answers (1)

Muniyappan
Active Contributor
0 Kudos

first try if this can be achieved by select query from sender channel itself. you can do the filtering in UDF but it is not required if the channel sql works out.

https://stackoverflow.com/questions/189213/sql-selecting-rows-by-most-recent-date

0 Kudos

Hi Muniyappan

Thanks for your response. Do we not need to create a receiver channel for JDBC look ups?

Regards

Sonal

Muniyappan
Active Contributor
0 Kudos

Receiver channel is required doing JDBC lookup. you have to construct the message type as per sql_query

https://help.sap.com/saphelp_nw73/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm

https://help.sap.com/saphelp_nw73/helpdata/en/44/7b7855fde93673e10000000a114a6b/content.htm

you can use select statement also to fetch records.Please check.

https://help.sap.com/saphelp_nw73/helpdata/en/44/7b7171fde93673e10000000a114a6b/content.htm

I thought you are fetching records from sender side. That is why i told to configure the sql query in sender channel. I misunderstood. Please ignore sender channel part.