For starters I wouldn't be using ALLTRIM in the SELECT - why not pad the variables out to the field length so that you don't need ALLTRIM ?
eg.
lcValue = PADR(lcValue,FSIZE("purno","po_main"))
lcValue2 = PADR(lcValue2,FSIZE("rcno","po_main"))
You should also ensure that the purno and rcno fields in both tables have indexes.
>Hi to all,
>
>how can change this select statement to become faster.
>please help
>
>thanks.
>
>select a.vendno,a.company,a.drno,a.rcno,a.purno,a.loctid,;
> a.adddate,a.addtime,a.adduser,a.org_rcno,b.item,b.qtyrec,b.umfact,;
> b.umeasur,b.cost,b.lineno,b.taxrate,b.qtyord,b.qtyrec2,;
> b.disc,b.qtyopen;
> from po_main a, po_detail b ;
> where alltrim(a.purno) == Lcvalue and alltrim(a.rcno) == Lcvalue2 and ;
> a.purno == b.purno and a.rcno == b.rcno AND b.qtyrec2 != 0 into cursor cur_temp
>
> select cur_temp
> go top
> scan
> insert into ictran01 (..,) values (cur_temp.,,,)
> select cur_temp
> endscan
Cheers,
Jamie