Reusable Queries

<< Click to Display Table of Contents >>

Navigation:  Concepts >

Reusable Queries

Many tools allow you to run SQL scripts.  However, what happens when you have to change them a little and then rerun?  Most people are not comfortable enough with SQL (and its many flavours - Oracle, MySQL, MS SQL, etc.) to make those changes.  Even if you took a simple SQL script to select only the male employees

 

         Select * from Employees where sex = 'M'

 

When they are modifying this there are various things to remember, single vs double quotes, lower case vs upper case, etc.  And this is just a simple example.  And each time you modify the query you introduce the possibility of breaking it.  

 

Imagine the case where you have to recall all the patients on a particular drug between two dates (or lot #s).  This then becomes more difficult to edit.  

 

InSights Into Data has a solution to this - and that is our concept of Reusable Queries.  We do this by extending standard SQL with our add-ons - allowing you to create queries that prompt the user to fill in information when the query is run.  This means that a query can be written once - and run many times using different data each time - without the user having to edit the query each time!!

 

InSights Into Data will build custom input dialogs when you run the query that allows the user to enter values or pick them from a list.  It is capable of taking in Strings, Numerics, and Dates as input.  It also has the capability of allowing the user to pick values from a list generated from a table in the database (ie lookup tables, etc.).

 

The following sample SQL - shows how this works.  The SQL has a where clause that after the equal sign is one of our custom Reusable Query clauses.  This clause string was created using one of our wizards (available in the query editor).  

 

Select *

from Employee

where Employee.TitleOfCourtesy =  :":LUSTRING:Select Title of Employee:True:False:False:[Dr.|Mr.|Ms.|Mrs.];"

 

When the query is run - the user is prompted to select the proper value for a TitleOfCourtesy as shown here...

 

         ReusableQueries_BuildDialog

 

Here you can see the dialog that is built from the options in the Text - allowing the user to either enter or pick from the list of possible options.  

 

This is a great way of allowing your users to choose from a restricted list of values when running SQL!!