Actually if you just want to execute an SQL statement, you can use the Database block, which is built for that purpose. Just drop the database block and write the SQL you want to be executed in the database.
You don't do that in advance. Before the Block 2 is reached, no task is created (I assume Block 2 is a task block, right)? You can't set a task status before it's created. I've been asking you specific and technical questions about database access, but what exactly you want to achieve (at a higher level)?
If you are using a script block, you can access the variable directly from script:
if my_variable = 'transition1' then // ...
If you are using a task block, there are some places you can refer to the variable content using brackets. For example, if you want to include the variable content in the subject or description of the task, you use: