It is not very clear to me if I can use a select-from statement as a condition for an IF STATEMENT For example
IF(SELECT quantity
FROM warehouse)>(SELECT quantity
FROM warehouse2) then ecc
Can I do something like that?
It is not very clear to me if I can use a select-from statement as a condition for an IF STATEMENT For example
IF(SELECT quantity
FROM warehouse)>(SELECT quantity
FROM warehouse2) then ecc
Can I do something like that?
I think you should using the variable for them.
DECLARE
V_quantity_WH1 NUMBER;
V_quantity_WH2 NUMBER;
BEGIN
--Sum qty 1 --------------
SELECT SUM(quantity) INTO V_quantity_WH1 FROM warehouse;
--Sum qty 2 --------------
SELECT SUM(quantity) INTO V_quantity_WH2 FROM warehouse2;
--Compare qty1 and qty2 ----------------
IF (V_quantity_WH1 > V_quantity_WH2) THEN
......;
END IF;
END;
It is impossible. The select ...
expression is a pointer, IF expects a boolean expression: IF *boolean_expression* THEN *statement* END IF;