VishalMistry
30th July 2015, 07:45
Hi all,

I am getting error "Incaompatible types for operand < (error 302)" when trying to compile script with following sql query:

I am refering to index 1 of whinr110 where it contains item,trdate,warehouse,sequence.

select whinr110.*
from whinr110
where whinr110._index1 < {:tcibd001.item, :date.fr , "CRMW", 1}
selecteos
opening.qty = opening.qty + whinr110.qhnd
endselect

Can anybody guide what is wrong with this query ?

Vishal

bhushanchanda
30th July 2015, 09:07
Hi,

You cannot use < sign like that. whinr110.cwar is of length 6 so you might need to add 2 spaces and index is is Item, Warehouse, Transaction Date, Sequence I guess. Also, I am guessing you want to pick the last record for his combination. So, its better to order by date and instead of looping through all the records, you can select only 1.

You can try the following 2 ways - A

db.set.to.default(twhinr110)
select whinr110.*
from whinr110
where whinr110._index1 inrange {:tcibd001.item, "CRMW ",0, 1}
and {:tcibd001.item , "CRMW ", :date.fr,1}
and whinr110.trdt <> :date.fr
order by whinr110.trdt desc
as set with 1 rows
selectdo
opening.qty = opening.qty + whinr110.qhnd
endselect

OR

db.set.to.default(twhinr110)
select whinr110.*
from whinr110
where whinr110._index4 = {:tcibd001.item, "CRMW "}
and whinr110.trdt < :date.fr
and whinr110.seqn = 1
order by whinr110.trdt desc
as set with 1 rows
selectdo
opening.qty = opening.qty + whinr110.qhnd
endselect

VishalMistry
30th July 2015, 09:24
Bhushan-Ji,

Thank you very very much. it worked.


Vishal