There is a query that i use very often on a daily basis. I usually run this same query several times using a different condition in the where clause throughout the day.
Given the following table:
columnA columnB columnC columnD
1 2 3 4
5 6 7 8
9 9 9 9
When i run my query i usually modify the where clause to get the results based on a particular column. Sometimes i would say 'where columnA=1' or i would change it to where columnB=3'.
To avoid having to retype the query everytime, i decided to script this in an SQL plus script.
To run the script i want to run it as follows:
> @myScript columnA 3
or
> @myScript columnC 7
Here is what i have so far:
define searchColumn=&&1
define searchParam=&&2
Select columnA, columnB, columnC,columnD
from myTable t
where t.'&searchColumn' in ('&searchParam')
The above doesnt work yet as it is complaining about the t.'&searchColumn'. How can i build the table name in the where clause that includes the prefix.
Additionally, if you have similar experiences where you have a set of common queries that you run every day, i would love to know how you use them to make your life easier. If there are better solutions i please let me know.
Thanks