I am trying to create a cursor called tmp1 which has all the fields from sellline and an additional field called vat. Basically the sellline.plu could be in one of three tables, stock, pack or opendept. Stock and Opendept are linked to the vat table by Stock.VAT or OpenDept.Vat = Vat.Sysref. Pack is linked to Stock by Pack.Unitplu = stock.plu.
The new table I require will have all the original sellline fields with the additional vat field with the appropriate vat percentage in that field. Is the SQL statement below close? it doesn't appear to work. Just takes ages as though it is in a loop.
SELECT Sellline.*, ;
VAT.Rate AS VAT ;
INTO cursor Tmp1 ;
FROM Sellline, Vat, Stock, PACK, OpenDept ;
WHERE (Stock.PLU = SELLLine.PLU ;
AND Stock.VAT = VAT.SYSREF) ;
OR (OpenDept.PLU = SELLLine.PLU ;
AND OpenDept.VAT = VAT.SYSREF)
OR (Pack.PLU = SELLLine.PLU ;
AND PACK.UnitPLU = STOCK.PLU ;
AND Stock.VAT = VAT.SYSREF )
The new table I require will have all the original sellline fields with the additional vat field with the appropriate vat percentage in that field. Is the SQL statement below close? it doesn't appear to work. Just takes ages as though it is in a loop.
SELECT Sellline.*, ;
VAT.Rate AS VAT ;
INTO cursor Tmp1 ;
FROM Sellline, Vat, Stock, PACK, OpenDept ;
WHERE (Stock.PLU = SELLLine.PLU ;
AND Stock.VAT = VAT.SYSREF) ;
OR (OpenDept.PLU = SELLLine.PLU ;
AND OpenDept.VAT = VAT.SYSREF)
OR (Pack.PLU = SELLLine.PLU ;
AND PACK.UnitPLU = STOCK.PLU ;
AND Stock.VAT = VAT.SYSREF )