Dynamic where clause in Automation Designer

Is it possible to construct your where clause in either an automation designer export dataset or execute script step by passing in variables? I'm trying to reuse a script in multiple export steps where the where clause changes between them. I'm updating the where clause by adding criteria to a variable and passing the variable to the script.

for example:
the script could be:
select 'x' from table where &1

the first data export/script execute would set a variable, where_clause, to "field1 = 123". The second export would set the where_clause variable to "field1 = 345 and field2 = 678".

The issue I'm running into is that the variable is getting expanded before it is sent to the SQL. Since automation designer variables are separated by spaces when being passed to a script, the script only gets field1 as the value for &1 (and then = would get passed as &2, 123 as &4, etc).

Is it possible to build up a dynamic where clause in automation designer?