我有以下代码:
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;
我想打印变量v_six_years的值,但是我收到错误:
ORA-06550: line 10,column 24: PLS-00306: wrong number or types of arguments in call to '||' ORA-06550: line 10,column 3
如何打印变量v_six_years的值?
解决方法
看来你不能连接varchar和boolean.
定义此功能:
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;
并使用它:
DBMS_OUTPUT.PUT_LINE('flag '|| BOOLEAN_TO_CHAR(v_six_years));