thibaan
2nd February 2006, 16:58
Hi folks,
I would like to know if somebody knows how can i use the "like" in my code.
I´m trying with these, but something are not happing... hehe
nome.o = strip$(shiftl$(tdcot991.fami.o)) &
" " &
strip$(shiftl$(tdcot991.grup.o)) &
" " &
strip$(shiftl$(tdcot991.sbgr.o)) & ".*"
select count(*):var
from tdcot995
where tdcot995.nome.o like """" & nome.o & """"
selectdo
endselect
I´d be thankfull if somebody help me!
mark_h
2nd February 2006, 17:07
(1) The code and utilities forum is for code you wish to share for others. The tools development forum is for questions such as yours.
(2) Search the forum and you will find plenty of posts on using like.
I have only done this using dynamic sql when using the like variable.
wild = ".*"
last4 = wild & some.project(3;4)
sql.code = ""
found = true
sql.code = sql.code & "select tppdm600.cprj "
sql.code = sql.code & "from tppdm600 "
sql.code = sql.code & "where tppdm600.cprj like " & chr$(34) & last4 & chr$(34)
sql.code = sql.code & " as set with 1 rows"
sql_id = sql.parse(sql.code)
sql.exec(sql_id)
while true
on case sql.fetch(sql_id)
case eendfile:
found = false
break
case 0:
found = true
break
default:
found = false
endcase
break
endwhile
sql.break(sql_id)
sql.close(sql_id)
if found then
return(true)
endif
The above is only an example - counting rows is something like the below code.
rows = 0
error.bypass = 1
sql = "select count(*):1 from " & table.name
sql_id = sql.parse(sql)
if sql_id<>0 then
sql.select.bind(sql_id, 1, rows)
sql.exec(sql_id)
while true
on case sql.fetch(sql_id)
case eendfile:
break
case 0:
break
default:
endcase
break
endwhile
sql.break(sql_id)
sql.close(sql_id)
endif
error.bypass = 0
return(rows)
Good Luck!
j_hass
2nd February 2006, 17:12
Hi Mark,
"Like" is a "very common" word and you cannot search for it in the forum.
Juergen
mark_h
2nd February 2006, 17:26
Hi Mark,
"Like" is a "very common" word and you cannot search for it in the forum.
Juergen
Yes you are correct. The point is that one should always try searching this forum first - being this was like the first post by the user I pointed out the correct forum and what they should do first. Everyone (including myself) should try searching the forum first. And I know as well as anybody how difficult it is sometimes searching the tools forum(I bookmark some just so I do not have to search). Usually if it is a tough search I will post a link - in this case a creative search using "sql" and "like" would return a bunch of threads, but it is easy to see a few of the newest threads deal with "like".
Next - even though I stated search the forum I did provide a solution. So it really was just a reminder. :D
thibaan
3rd February 2006, 12:33
Hi Mark,
Thank you for the explanation. As you said i´m a new baanboard´s user.
I´ll try to use this code.
Thiago.
Rita Kotecha
3rd February 2006, 13:39
Hi,
Please modify the coloured part and try.
nome.o = ".*" & strip$(shiftl$(tdcot991.fami.o)) &
" " &
strip$(shiftl$(tdcot991.grup.o)) &
" " &
strip$(shiftl$(tdcot991.sbgr.o)) & ".*"
select count(*):var
from tdcot995
where tdcot995.nome.o like """" & nome.o & """"
selectdo
endselect