ACCEPT scale PROMPT 'Enter your input scale (C or F) for temperature: ';
ACCEPT temp PROMPT 'Enter your temperature value to be converted: ';
DECLARE
v_scale CHAR(1) := UPPER('&scale');
v_temp NUMBER := '&input';
BEGIN
IF (v_scale) = ('F') THEN
v_temp := (v_temp - 32) * 5/9;
DBMS_OUTPUT.PUT_LINE ('You converted temperature in C is exactly ' || TO_CHAR(v_temp));
ELSIF (v_scale) = ('C') THEN
v_temp := (v_temp * 9/5) + 32;
DBMS_OUTPUT.PUT_LINE ('You converted temperature in F is exactly ' || TO_CHAR(v_temp));
ELSE
DBMS_OUTPUT.PUT_LINE ('This is NOT a valid scale. Must be C or F.');
END IF;
END;
/
运行代码时,它要求我输入2个输入,例如F和100。 然后,它仅显示“ PL / SQL过程已成功完成” 。
看起来它从未运行过 DBMS_OUTPUT.PUT_LINE ??怎么来的??我是pl sql的新手,所以对上面的newvie错误感到抱歉
谢谢
答案 0 :(得分:1)
尝试在脚本的开头添加SET SERVEROUTPUT ON
。