DBeaver - start running code after declaring and setting a variable

335 Views Asked by At

I have a simple select statement in DBeaver which uses the same table name twice. To avoid typing it in twice, I have a @set statement to store the table name. However, if I select everything and try to run it, it stalls at the @set statement and doesn't move on to the select statement. What keyword or command am I missing to enable me to run this code in one go?

If this were "normal" SQL, I would probably use a return or go command, but DBeaver doesn't seem to like either of these.

1

There are 1 best solutions below

2
Zufar Sunagatov On

What keyword or command am I missing to enable me to run this code in one go?

To run a @set statement and a select statement in one go in DBeaver, you can use the semicolon ; character as a separator like that:

@set table_name = 'my_table';
select * from ${table_name};

I hope it can help you.