I have the following code:
DECLARE
v_hire_date DATE:='30-Oct-2000';
v_six_years BOOLEAN;
BEGIN
IF MONTHS_BETWEEN(SYSDATE,v_fecha_contrato)/12 > 6 THEN
v_six_years:=TRUE;
ELSE
v_six_years:=FALSE;
END IF;
DBMS_OUTPUT.PUT_LINE('flag '||v_six_years);
END;
I want to print the value of the variable v_six_years
, but I am getting the error:
ORA-06550: line 10, column 24:
PLS-00306: wrong number or types of arguments in call to '||'
ORA-06550: line 10, column 3
How to print the value of the variable v_six_years
?
It seems you cannot concat varchar
and boolean
.
Define this function:
FUNCTION BOOLEAN_TO_CHAR(FLAG IN BOOLEAN)
RETURN VARCHAR2 IS
BEGIN
RETURN
CASE FLAG
WHEN TRUE THEN 'TRUE'
WHEN FALSE THEN 'FALSE'
ELSE 'NULL'
END;
END;
and use it like this:
DBMS_OUTPUT.PUT_LINE('flag '|| BOOLEAN_TO_CHAR(v_six_years));
You can use below to print Boolean Value in PLSQL
dbms_output.put_line('v_six_years '|| sys.diutil.bool_to_int(v_six_years));
dbms_output.put_line
is not overloaded to accept a boolean argument.Simple one line answer would be
dbms_output.put_line(case when v_six_years = true then 'true' else 'false' end );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With