Reputation: 87
I use SQL *PLUS to run this code
DECLARE
v_sal NUMBER:= 3000;
v_valid BOOLEAN;
BEGIN
v_valid := v_sal BETWEEN 1000 AND 5000;
DBMS_OUTPUT.PUT_LINE('Value of v_valid is ' || v_valid);
END;
/
I read that I can use this expression to assign boolean value. Why then I get this error @ line 6?
Upvotes: 1
Views: 94
Reputation: 2664
I don't think the problem is the BETWEEN expression. It's the DBMS_OUTPUT line. It can't handle BOOLEAN values. The following code works:
set serveroutput on
DECLARE
v_sal NUMBER:= 3000;
v_valid BOOLEAN;
BEGIN
v_valid := v_sal BETWEEN 1000 AND 5000;
dbms_output.put_line(CASE WHEN v_valid THEN 'true' ELSE 'false' END);
END;
/
Upvotes: 2