baantl
18th May 2005, 05:55
hi everyone i would like to ask how to using like statement
as the example


item.forloop = timrp010.item

select timrp001.orno, timrp001.pono
from timrp001
where timrp010.item like 'item.forloop & ".*"'
selectdo
xxx
selectempty
xxx
endselect

can anyone give me ideal to use parameter in like sql statement
thank you.... :rolleyes:

baanbomb
18th May 2005, 06:23
hi,
select timrp001.orno, timrp001.pono
from timrp001
where timrp010.item like "eitem.*"
selectdo
xxx
selectempty
xxx
endselect

dorleta
18th May 2005, 10:18
The best that you can do is to use dynamic SQL .

the way is to create a string and after execute it. This is an example from baan help.

Table tppmod090
Long sql

Long total, m_val

m_val = 25
if ( not sql ) then
sql = sql.parse(
"select ppmod090.fld1, count(*):1 " &
"from ppmod090, ppmod091 " &
"where ppmod090.fld2 = ppmod091.fld5 AND " &
"ppmod091.fld3 > :2 " &
"group by ppmod090.fld1 " &
"order by 2")
endif
sql.select.bind(sql, 1, total)
sql.where.bind(sql, 2, m_val)
sql.exec(sql)
while ( true )
on case ( sql.fetch(sql) )
case eendfile:
break
case 0:

print_info(ppmod090.fld1, total)
continue
default: | error
message("Error %d occurred", db.error)
endcase
break
endwhile
sql.break(sql)
sql.close(sql) | After sql.close, a new sql.parse must be
sql = 0 | executed to give sql a correct value. If the
| last two lines are skipped, sql retains a

| correct value.

See Embedded SQL for an example of the same query executed using embedded SQL.

© 1998 Baan Development B.V. All rights reserved