Код: Выделить всё
product{PROP:SQL}='UPDATE product t1 ' &|
' JOIN valute t2 on t2.valute_id = t1.VAL_START ' &|
' JOIN valute t3 on t3.valute_id = t1.VAL_SALE ' &|
' SET t1.PRICE_SALE = ' &|
'( CASE ' &|
' WHEN t1.VAL_START = t1.VAL_SALE AND t1.NACHENKA > 0 THEN t1.PRICE_START + t1.PRICE_START * t1.NACHENKA/100 ' &|
' WHEN t1.VAL_START <> t1.VAL_SALE AND t1.NACHENKA > 0 THEN ' &|
' CASE ' &|
' WHEN t2.CURR_TODAY = 1 THEN IF (t3.FUNC='/',' &|
' (t1.PRICE_START + t1.PRICE_START * t1.NACHENKA/100)*t3.CURR_TODAY,' &|
' (t1.PRICE_START + t1.PRICE_START * t1.NACHENKA/100)/t3.CURR_TODAY)' &|
' WHEN t3.CURR_TODAY = 1 THEN IF(t2.FUNC='/',' &|
' (t1.PRICE_START + t1.PRICE_START * t1.NACHENKA/100)/t2.CURR_TODAY,' &|
' (t1.PRICE_START + t1.PRICE_START * t1.NACHENKA/100)*t2.CURR_TODAY)' &|
' ELSE t1.PRICE_SALE ' &|
' END ' &|
' END ) ;'
IF ErrorCode() THEN Message('Файл: ' & Choose(Error()=FileSystemErr, FileError(), Error())) END
Код: Выделить всё
UPDATE product t1
JOIN valute t2 on t2.valute_id = t1.VAL_START
JOIN valute t3 on t3.valute_id = t1.VAL_SALE
SET t1.PRICE_SALE =
CASE
WHEN (t1.VAL_START = t1.VAL_SALE AND t1.NACHENKA > 0) THEN t1.PRICE_START + t1.PRICE_START * t1.NACHENKA/100
WHEN (t1.VAL_START <> t1.VAL_SALE AND t1.NACHENKA > 0) THEN
CASE
WHEN t2.CURR_TODAY = 1 THEN IF( t3.FUNC='/',
(t1.PRICE_START + t1.PRICE_START * t1.NACHENKA/100)*t3.CURR_TODAY,
(t1.PRICE_START + t1.PRICE_START * t1.NACHENKA/100)/t3.CURR_TODAY )
WHEN t3.CURR_TODAY = 1 THEN IF( t2.FUNC='/',
(t1.PRICE_START + t1.PRICE_START * t1.NACHENKA/100)/t2.CURR_TODAY,
(t1.PRICE_START + t1.PRICE_START * t1.NACHENKA/100)*t2.CURR_TODAY )
ELSE t1.PRICE_SALE
END
END;
![Smile :)](./images/smilies/icon_smile.gif)