LOOKUP Failing (4 replies)
Arline....
- Change the Where clause in the lookup to.
CUSTOMER = '%1'
See this link for more details on how the parameters are passed from the Lookup function to the SQL query.
- You cannot return multiple records from a Lookup. You will get an error. If you need to get a list of values you need to do some trickery with your SQL to get the list.
Here's a link to a document explaining how you can do this. Preferred option is #1 assuming you're not targeting a SQL2017 database.
https://www.mytecbits.com/microsoft/sql-server/concatenate-multiple-rows-into-single-string
Also, your syntax for the lookup is incorrect.
Just use the following...
Lookup("VALIDORD", “ORDNUMBER”, %CUSTOMER, true)
Thanks for the suggestions. Actually I was getting errors with that syntax as well, so I changed to the Array.
Thanks for the ideas on the lookup workarounds. Just wondering...should I being instead using Hierarchy transform? I could try to reverse what I'm doing, and return a big result set of orders first, THEN sum them up, instead of doing it the other way around. Is there a best practice?
Arline, I am not sure what you're trying to achieve, so difficult to say.
A hierarchy will work.
Goal:
Return a list of all the orders from a Lookup where there is a match on the CUSTOMER field in my IMAN map transform
Error when doing a map transform for a new field, ORDNUMBER:
Lookup in Map Transform:
Lookup("VALIDORD", “ORDNUMBER”, Array(%[CUSTOMER], true)
Lookup in Setup:
See image attached.
Thanks for any advice.