我正在尝试使用Bind Variables。但是被困在这件作品上。无法编译它: -
VARIABLE b_basic_percent NUMBER
VARIABLE b_pf_percent NUMBER
DECLARE
v_today DATE:=SYSDATE;
v_tomorrow v_today%TYPE;
BEGIN
v_tomorrow:=v_today +1;
:b_basic_percent:=45;
:b_pf_percent:=12;
DBMS_OUTPUT.PUT_LINE(' Hello World ');
DBMS_OUTPUT.PUT_LINE('TODAY IS : '|| v_today);
DBMS_OUTPUT.PUT_LINE('TOMORROW IS : ' || v_tomorrow);
PRINT b_basic_percent
PRINT b_pf_percent
END;
有人可以帮助我了解我哪里出错了吗?
答案 0 :(得分:0)
PRINT
是SQL * Plus命令,而不是PL / SQL命令。因此,它应该在之后>强调PL / SQL块(与块之前发生的VARIABLE
非常相似),如下所示:
variable b_basic_percent number
variable b_pf_percent number
declare
v_today date:=sysdate;
v_tomorrow v_today%type;
begin
v_tomorrow := v_today + 1;
:b_basic_percent := 45;
:b_pf_percent := 12;
dbms_output.put_line(' Hello World ');
dbms_output.put_line('TODAY IS : '|| to_char(v_today, 'dd Mon yyyy'));
dbms_output.put_line('TOMORROW IS : ' || to_char(v_tomorrow, 'dd Mon yyyy'));
end;
/
print b_basic_percent
print b_pf_percent
Hello World
TODAY IS : 05 Nov 2015
TOMORROW IS : 06 Nov 2015
b_basic_percent
---------------
45
b_pf_percent
------------
12