This article transferred from: Http://stackoverflow.com/questions/5653423/how-do-i-use-variables-in-oracle-sql-developer
Below is a example of using variables in SQL Server 2000.
DECLARE @EmpIDVar INTSET @EmpIDVar = 1234SELECT *FROM EmployeesWHERE EmployeeID = @EmpIDVar
I want to does the exact same thing in Oracle using SQL Developer without additional complexity. It seems like a very simple thing to does, but I can ' t find a simple solution. How can I do it?
You can read up elsewhere on substitution variables; They ' re quite handy in SQL Developer. But I had fits trying to use bind variables in SQL Developer. What I do:
SET SERVEROUTPUT ONdeclare v_testnum number; v_teststring varchar2(1000);begin v_testnum := 2; DBMS_OUTPUT.put_line(‘v_testnum is now ‘ || v_testnum); select 36,‘hello world‘ INTO v_testnum, v_teststring from dual; DBMS_OUTPUT.put_line(‘v_testnum is now ‘ || v_testnum); DBMS_OUTPUT.put_line(‘v_teststring is ‘ || v_teststring);end;
SET SERVEROUTPUT ON
Makes it so text can is printed to the script output console.
Go How does I use the variables in Oracle SQL Developer?