jdhc3m
2nd February 2011, 14:22
Morning
I usually "Like" this:
tisfc010.item like ".*Hammer.*"
But now, I have to use as a variable
example:
tisfc010.item like ".*Item.*"
How can I use the "Like" to a variable?
Celeron.JB
2nd February 2011, 14:37
Hi
Faced with such a problem, one way to use Dynamic sql
Celeron.JB
2nd February 2011, 15:02
Something like this:
long like.var
string sql1.str(1500)
long sql1
on case like.var
case 1:
sql1.str = "select tcibd001.item, "&
"tcibd001.dsca "&
"from tcibd001 "&
"where tcibd001.dsca like '.*Hammer.*' "
break
case 2:
sql1.str = "select tcibd001.item, "&
"tcibd001.dsca "&
"from tcibd001 "&
"where tcibd001.dsca like '.*Item.*' "
break
endcase
if ( not sql1 ) then
sql1 = sql.parse( sql1.str )
endif
sql.exec(sql1)
while ( true )
on case ( sql.fetch(sql1) )
case eendfile:
break
case 0:
|selectdo
brp.ready( brp_id1 ) |
|endselect
continue
default: | error
message("Error %d occurred", db.error())
endcase
break
endwhile
sql.break(sql1)
sql.close(sql1)
sql1 = 0
mark_h
2nd February 2011, 16:14
And if in your example item is a variable string you could just change the above
"where tcibd001.dsca like '.*" & item & ".*' " . You can use string variables to build the query.
jdhc3m
2nd February 2011, 18:51
Thanks guys, I got this:
tisfc010.item like ".*" & :item.o & ".*"