码迷,mamicode.com
首页 > 数据库 > 详细

[转]How do I use variables in Oracle SQL Developer?

时间:2016-04-01 12:54:48      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:

本文转自:http://stackoverflow.com/questions/5653423/how-do-i-use-variables-in-oracle-sql-developer

Below is an example of using variables in SQL Server 2000.

DECLARE @EmpIDVar INT

SET @EmpIDVar = 1234

SELECT *
FROM Employees
WHERE EmployeeID = @EmpIDVar

I want to do the exact same thing in Oracle using SQL Developer without additional complexity.  It seems like a very simple thing to do, 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 have fits trying to use bind variables in SQL Developer.  This is what I do:

SET SERVEROUTPUT ON
declare
  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 be printed to the script output console.

 

[转]How do I use variables in Oracle SQL Developer?

标签:

原文地址:http://www.cnblogs.com/freeliver54/p/5344413.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!