Sparse look up query
Moderators: chulett, rschirm, roy
Sparse look up query
Hello all,
I have the following scenario
Source file - transformer - look up database (being looked up sparse look up )-output
The idea is for each row value (varchar) , I need to to break the string into words (which I am handling with loop variables) and look up each word to database to get matching records
For example
Source input is "A BMP C D XYZ" then I break them up into 'A' , 'BMP','C','D','XYZ' in a separate row say Input_break (Which I have already tested) and do a sparse look up where database column_name like '%orchestrate.Input_break%'
The problem : I am expecting a lot of records out of database (because a lot of rows do exist in database satisfying the query) , However , I only get 5 rows in the output all of which populate a null (or empty) database column_name along with each word (for the input_break) column
Output
input_break,database_colume_name
'A' ,
'BMP',
'C',
'D',
'XYZ',
Thanks for looking
I have the following scenario
Source file - transformer - look up database (being looked up sparse look up )-output
The idea is for each row value (varchar) , I need to to break the string into words (which I am handling with loop variables) and look up each word to database to get matching records
For example
Source input is "A BMP C D XYZ" then I break them up into 'A' , 'BMP','C','D','XYZ' in a separate row say Input_break (Which I have already tested) and do a sparse look up where database column_name like '%orchestrate.Input_break%'
The problem : I am expecting a lot of records out of database (because a lot of rows do exist in database satisfying the query) , However , I only get 5 rows in the output all of which populate a null (or empty) database column_name along with each word (for the input_break) column
Output
input_break,database_colume_name
'A' ,
'BMP',
'C',
'D',
'XYZ',
Thanks for looking
Without testing - and this is pure speculation, I am guessing that the problem is that like statement is looking for the literal '%orchestrate.Input_break%' rather than the value that you are actually wanting to pass to that value.
I have never tried to pass a like statement to a sparse lookup. But as a guess I would think that you might have to pass the % as part of your text and just have in the query column_name like orchestrate.Input_break
where input_break would equal %value%.
Again this is all just a guess.
I have never tried to pass a like statement to a sparse lookup. But as a guess I would think that you might have to pass the % as part of your text and just have in the query column_name like orchestrate.Input_break
where input_break would equal %value%.
Again this is all just a guess.
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
Thanks for all your inputs
Firstly I checked if my column name is exactly what I get in the transformer and then I took off the % sign , I get the exact same result , this tells me there is something wrong , but I just don't know what is it .
Secondly , I did check the number of records with like statement in database and I am getting plenty on each word .
Finally, When I try to test it with an = sign instead of like and ensuring the record I test exists in database , I get the correct result .
Firstly I checked if my column name is exactly what I get in the transformer and then I took off the % sign , I get the exact same result , this tells me there is something wrong , but I just don't know what is it .
Secondly , I did check the number of records with like statement in database and I am getting plenty on each word .
Finally, When I try to test it with an = sign instead of like and ensuring the record I test exists in database , I get the correct result .
Last edited by devsonali on Tue Jun 30, 2015 12:51 pm, edited 5 times in total.
INSTR will indeed give the position. However if returned value is greater than 0, then string is present.i.e
Code: Select all
WHERE INSTR(Tab_Col,searched_string) >0
We don't know the root cause of this issue. However if the issue is due to "like" clause then INSTR can be used.
is equivalent of
Code: Select all
WHERE INSTR(Tab_Col,searched_string) >0
Code: Select all
WHERE Tab_Col like "%searched_string%"
Now , I see what your were saying , Yes the query works fine but only in external sql portal , not in database stage (Oracle)
However , if I hard code with a value say 'A' to test the sql
Instead of 'ORCHESTRATE.searched_string'
select tab_col from table_T
WHERE INSTR(Tab_Col,'A') >0 then I get required rows in datastage
When I try INSTR(Tab_Col,'ORCHESTRATE.searched_string') >0 , I get only 5 ROWS (Just as how I got by using LIKE statement)
Thanks again
However , if I hard code with a value say 'A' to test the sql
Instead of 'ORCHESTRATE.searched_string'
select tab_col from table_T
WHERE INSTR(Tab_Col,'A') >0 then I get required rows in datastage
When I try INSTR(Tab_Col,'ORCHESTRATE.searched_string') >0 , I get only 5 ROWS (Just as how I got by using LIKE statement)
Thanks again
Try without enclosing searched string in quotes i.e.
Code: Select all
INSTR(Tab_Col,ORCHESTRATE.searched_string) >0