lorry.lu
29th November 2018, 18:27
Dear All

I want to use a variable in "Like" function in select statement.
But I failed, please advise how to use a variable?

My scripts is as below: (it didn't work)

domain tcrefa tmp.refa
tmp.refa = "369/500001.*"
select tdsls041.orno, tdsls041.refa
from tdsls041
where tdsls041.refa like :tmp.refa

but if I change to below, it works fine.

|tmp.refa = "369/500001.*"
select tdsls041.orno, tdsls041.refa
from tdsls041
where tdsls041.refa like "369/500001.*"

But the tmp.refa is an calculation field, it is the combination of Baan Company + "/" + Order Number, and I had to use a variable to store this value. So how to achieve it?

Thanks in advance.
BR/Lorry Lu

oirfeodent
30th November 2018, 14:28
Dear All

I want to use a variable in "Like" function in select statement.
But I failed, please advise how to use a variable?

My scripts is as below: (it didn't work)

domain tcrefa tmp.refa
tmp.refa = "369/500001.*"
select tdsls041.orno, tdsls041.refa
from tdsls041
where tdsls041.refa like :tmp.refa

but if I change to below, it works fine.

|tmp.refa = "369/500001.*"
select tdsls041.orno, tdsls041.refa
from tdsls041
where tdsls041.refa like "369/500001.*"

But the tmp.refa is an calculation field, it is the combination of Baan Company + "/" + Order Number, and I had to use a variable to store this value. So how to achieve it?

Thanks in advance.
BR/Lorry Lu

Try below
domain tcrefa tmp.refa
tmp.refa = "369/500001.*"
select tdsls041.orno, tdsls041.refa
from tdsls041
where tdsls041.refa like :1
wherebind(1, tmp.refa)