I regularly have to do support at work using various database tables, checking and comparing values between different tables but always from a starting point of a set of ID values, as strings.
I've set up and saved a SQL Worksheet that I use with all of the various queries I run to do this support, but it takes a lot of copy/pasting of these ID values (in different orders) into all of the different queries. So I'm trying to automate and optimize my time a little.
What I'm hoping to achieve is, at the top of this worksheet, to paste in my ID values as a comma-separated list, store it into a variable somehow, and then run individual queries on the same worksheet and have them use the current value of that variable in their WHERE clauses.
For example,
select 'A1234', 'B5678' into ids from dual; select id, status from tableA where id in ids; select id_2, status_2 from tableB where id in ids; Since I'm not running this as a script from top to bottom, I don't think this method would directly work but is there something similar or can I be pointed in the right direction?
As a bonus if possible, I'm also hoping to not need to add the quotation marks (') myself, and rather somehow just use, for example, A1234,B5678 and have it do the work for me but this isn't necessary, just saves me a little bit of time.