# Bind variables across multiple SQL statements in same script without re-prompting?

**URL:** <https://forums.toadworld.com/t/bind-variables-across-multiple-sql-statements-in-same-script-without-re-prompting/57542>\
**Category:** Toad Data Point & Toad Intelligence Central\
**Created:** [May 16, 2023, 4:26pm UTC](https://forums.toadworld.com/t/bind-variables-across-multiple-sql-statements-in-same-script-without-re-prompting/57542 "2023-05-16T16:26:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HansFumer](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@HansFumer](https://forums.toadworld.com/u/HansFumer)\
**Post date:** [May 16, 2023, 4:26pm UTC](https://forums.toadworld.com/t/bind-variables-across-multiple-sql-statements-in-same-script-without-re-prompting/57542/1 "2023-05-16T16:26:07Z")

</div>

As example, if I run the following two statements to be prompted for variable values, I get re-prompted on each script. This of course gets old really fast. Is there some basic means to have the thing run end-to-end without re-prompting and without getting into the proprietary overhead of using the Automation bells and whistles?

select \*  
from SalesMonth{{Quote(:yyyymm)}} s  
where s.saleamount\>{{Quote(:min\_sale\_amt)}}  
order by saleamount desc;

select \*  
from SalesMonth{{Quote(:yyyymm)}} s  
where s.region={{Quote(:what\_region)}}  
order by saleamount desc;

---

<div class="post-metadata">

**Author:** ![Gary.Jerep](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/gary.jerep/32/205_2.png) [@Gary.Jerep](https://forums.toadworld.com/u/Gary.Jerep)\
**Post date:** [May 16, 2023, 5:00pm UTC](https://forums.toadworld.com/t/bind-variables-across-multiple-sql-statements-in-same-script-without-re-prompting/57542/2 "2023-05-16T17:00:22Z")

</div>

There is a way to do this via the Bind Variable Store in the Toad Views panel (accessible by the **Toad-\>Toad Views** pull down menu). Assuming that it's ok to specify the bind variable values _before_ script execution, hit the (x)= button at the top of the Toad Views menu and you can furnish your values there, per snap below.

If you need to be prompted at runtime, then you'll probably either need to use Automation, or declare your bind variables in a code block. Hope this helps.

 ![image](https://global.discourse-cdn.com/quest/original/2X/0/0cfac75e062437b467ae6446f77811e6b9958422.png)

---

<div class="post-metadata">

**Author:** ![HansFumer](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@HansFumer](https://forums.toadworld.com/u/HansFumer)\
**Post date:** [May 16, 2023, 5:41pm UTC](https://forums.toadworld.com/t/bind-variables-across-multiple-sql-statements-in-same-script-without-re-prompting/57542/3 "2023-05-16T17:41:18Z")

</div>

Thx Gary. Only through your reply here did I unravel what the help text actually meant about how to make these values more stored/global.

When you say _declare your bind variables in a code block_, I know what you mean in general, though not specifically. So you maybe you mean... have PL/SQL upfront that just does a bunch of _Declare_ statements... or something else?

---

<div class="post-metadata">

**Author:** ![Gary.Jerep](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/gary.jerep/32/205_2.png) [@Gary.Jerep](https://forums.toadworld.com/u/Gary.Jerep)\
**Post date:** [May 16, 2023, 5:56pm UTC](https://forums.toadworld.com/t/bind-variables-across-multiple-sql-statements-in-same-script-without-re-prompting/57542/4 "2023-05-16T17:56:19Z")

</div>

Right, or an anonymous block that has your declares and var assignments...  
See [this helpful link](https://www.oracletutorial.com/plsql-tutorial/plsql-variables/) (among many others) for further guidance.
