SQLite Forum

.read with parameters... or alternative?
Login
Back before I retired and I was still using Oracle, I had dozens of little SQL scripts that I used to enter common queries or perform other functions.  A typical script, that I used often was this one called “count”:

    select &2, count(*) from &1 group by &2;

And, I could use that script by entering something like:

    @count employee department

... to see how many employees were in each department.  This was a feature of Oracle’s interactive tool called SQL*Plus, which is analogous to the sqlite3 command interface.

I sorely miss the ability to pass parameters to little scripts like this.  I’m a terrible typist and the less I need to type, the happier I am.

So, I suppose I could write a shell script that would write the SQLite script to a file, filling in parameter values, and then execute that file.  Is that the easiest way to achieve something like this?  Or is there an easier way?