SQLite Forum

Feature request: Stored Procedures
Login
Until now SQLite3 does not support Stored Procedures (at least as far as I am aware)

Since many more than 10 years I am using therefore my own extension functions to mimic such a feature. I named my function "call" and its first parameter is the name of the procedure and the other parameters are the inputs to that function.

The call function inserts the parameters into a table with name "stack", which fires a trigger which is watching the name, the first parameter of my call.

The trigger itself can work with all the parameters from the stack record, a helper extension function supports this task.

The trigger itself calls a function return, which can be filled into the stack record but more important becomes the return value of the "call" extended function call and therefore is then the reply into the original sql statement, which caused the trigger to fire.

Because all this happens in scope of the same db context the stack leaves only a trace if there was no delete all from stack happening. I am controlling this for debug purposes, too.

Here is an example for the recursive form of the faculty for number 6 ( =  1 * 2 * 3 * 4 * 5 * 6 = 720 )

~~~
D:\SQLite3x\sandbox>sqlite3 LoadExTest.SQB
SQLite version 3.35.5 2021-04-19 18:32:05
Enter ".help" for usage hints.
sqlite> .load sqlite3.dll
sqlite> .mode box
sqlite> select call('Fakt',6);
┌────────────────┐
│ call('Fakt',6) │
├────────────────┤
│ 720            │
└────────────────┘
sqlite>
~~~

Are there any plans to introduce also Stored Procedures into SQLite3 ?