SQLite Forum

.read with parameters... or alternative?
Login
If I am understanding your question as you meant it, in the context of your original question: You want to be able, within a sqlite3 shell session, with a transaction open, enter something like

> @count employee department

, (where "@count" stands for running a predefined query (or D{D,M}L statement) having numbered parameters to be bound to "employee" and "department", standing for literals.) Then you want to either abort or commit the transaction.

For that, my suggestions of a scripting language approach are not going to work, at least not in any simple way. (One can imagine using the .shell command, followed by a .read of something the system shell leaves behind, but that defeats the convenience purpose of that nice "@function param1 ..." invocation.)

A simple enhancement of the SQLite shell's .read command would accomplish that convenient nicety. If the FILE parameter to .read could optionally be "-cmd some_doer params ...", where that meant to run some_doer in the system shell with the given params, and pass its output into the SQLite shell as meta-commands and queries (just as .read does now with FILE content), it would provide close to the same convenience of the "@whatever params" construct. Or, a new meta-command doing that would reduce typing a tad.

As I said, such a modification would be relatively easy for an experienced C programmer.