# Using Variables

**URL:** <https://forums.toadworld.com/t/using-variables/5985>\
**Category:** Toad Data Point & Toad Intelligence Central\
**Created:** [May 1, 2009, 2:54pm UTC](https://forums.toadworld.com/t/using-variables/5985 "2009-05-01T14:54:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Huzaifah](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/huzaifah/32/76_2.png) [@Huzaifah](https://forums.toadworld.com/u/Huzaifah)\
**Post date:** [May 1, 2009, 2:54pm UTC](https://forums.toadworld.com/t/using-variables/5985/1 "2009-05-01T14:54:58Z")

</div>

Hi–

I am trying to define a variable and then use it in a query. As I am defining it in the code, I don’t want to be prompted with the “Bind Variables” box. I must be doing something wrong because the variable is not getting defined and I always get prompted with the “Bind Variables” box:

VARIABLE VAR1 NUMBER;  
EXEC :VAR1 := 1;  
SELECT \*  
FROM “TRANSACTION” tt  
WHERE tt.bllng\_id = :var1;

Thanks for the help!!

---

<div class="post-metadata">

**Author:** ![Debbie\_Peabody](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/debbie_peabody/32/18_2.png) [@Debbie\_Peabody](https://forums.toadworld.com/u/Debbie_Peabody)\
**Post date:** [May 1, 2009, 3:44pm UTC](https://forums.toadworld.com/t/using-variables/5985/2 "2009-05-01T15:44:39Z")

</div>

I’m not completely certain what database type you are using. If you are using Oracle use an anonymous block by using BEGIN and END. If Sql Server use the @ symbol instead of colon.

Debbie

---

<div class="post-metadata">

**Author:** ![Huzaifah](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/huzaifah/32/76_2.png) [@Huzaifah](https://forums.toadworld.com/u/Huzaifah)\
**Post date:** [May 1, 2009, 4:04pm UTC](https://forums.toadworld.com/t/using-variables/5985/3 "2009-05-01T16:04:31Z")

</div>

Thanks Debbie. I am using Oracle. Could you provide a sample of the anonymous block? I have tried to do this via snippets taken from the web but can not get it working. Thank you!

---

<div class="post-metadata">

**Author:** ![Debbie\_Peabody](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/debbie_peabody/32/18_2.png) [@Debbie\_Peabody](https://forums.toadworld.com/u/Debbie_Peabody)\
**Post date:** [May 1, 2009, 4:25pm UTC](https://forums.toadworld.com/t/using-variables/5985/4 "2009-05-01T16:25:50Z")

</div>

DECLARE

VAR1 **CHAR** := ‘X’;

VAR2 **CHAR** ;

SELECT ‘1’ INTO VAR2

WHERE dummy = VAR1;

END;

You don’t really want to bind the variable but just define and use the variable. Simpel example below.

BEGIN FROM dual tt
