Question: I come from a sql server background. Frequently when trying to build some reports or answer questions from the database I would write queries that use a variable several times within the query. Rather than update the value 3-4 times each time I want to change the query I would use a variable so I can update the value only once. For brevity I have written a simple query below that illustrates what I would do in SQL Server when trying to pull a report. 

```
declare @test numeric(3)
select @test = 683
select myColumn from myTable where myColumn = @test

```

What is the equivalent of this in oracle? I tried to write something similar but got some error messages about requiring an into statement. From what I can gather you can select something into a variable in oracle but you cant use a variable in a read only fashion like I have done above. Is it even possible to write a query similar to the one above in oracle?

Answer: 
**Declare:**

```
SQL> variable x number

```

**Assign:**

```
SQL> begin :x := 3; end;
  2  /
PL/SQL procedure successfully completed.

```

**Use:** 

```
SQL> select :x from dual;
        :X
----------
         3
1 row selected.

```

Note: In Oracle, : is used instead of @, as in :x instead of @x; and the assignment operator is :=, not =.
If you are using SQL Developer, write the query and use for variables ':'

```
select myColumn from myTable where myColumn = :test

```

When you start (Ctrl-Enter) the query, the SQL Developer will ask for the value of :test. 

If you want to change the select statement dynamically, see [this](https://stackoverflow.com/questions/5653423/how-do-i-use-variables-in-oracle-sql-developer) answer:

```
define value1 = 'sysdate+3 as mydate';
SELECT &&value1 from dual;

```