3 回答

TA貢獻1801條經驗 獲得超8個贊
我正在使用3.2版中的SQL-Developer。其他東西對我不起作用,但是這樣做:
define value1 = 'sysdate'
SELECT &&value1 from dual;
這也是這里介紹的最巧妙的方法。
(如果省略“定義”部分,則將提示您輸入該值)

TA貢獻1858條經驗 獲得超8個贊
在SQL * Plus中,您可以執行類似的操作
SQL> variable v_emp_id number;
SQL> select 1234 into :v_emp_id from dual;
1234
----------
1234
SQL> select *
2 from emp
3 where empno = :v_emp_id;
no rows selected
在SQL Developer中,如果您運行的語句具有任意數量的綁定變量(以冒號作為前綴),則會提示您輸入值。正如Alex指出的,您還可以使用“運行腳本”功能(F5)和Alex建議的替代EXEC語法來執行類似的操作。
variable v_count number;
variable v_emp_id number;
exec :v_emp_id := 1234;
exec select count(1) into :v_count from emp;
select *
from emp
where empno = :v_emp_id
exec print :v_count;
- 3 回答
- 0 關注
- 1394 瀏覽
添加回答
舉報