I'm following up to myself here.
I would like to have some advice from you guys about the design of the API.
Currently, the API for select and update is the following:
database_id FN 'statement' [argument ...]
In other words, the first element of the ravel of the right-hand argument is the SQL statement itself, and the remaining elements are the positional arguments.
Now, I was thinking of allowing a two-dimensional array for the arguments. This would effectively run the same update for each row (using a prepared statement). You could do some cool stuff like feeding the result of a query into another:
result ← db SQL[3] 'select a,b from foo'
db SQL[4] 'insert into bar (a,b) values (?,?)' result
However, parsing the right-hand arguments here is a bit ugly, since the interpretation of the arguments are significantly different depending on whether the second value of the ravel is two-dimensional. I find that to be very ugly.
Another alternative is to have a separate function number for this particular case. Yet another option would be to pass the db and the SQL statement on the left-hand side. This would be messy in the case where there are no positional parameters though (since the left hand argument can't be empty).
What are your suggestions as to how to design this?
Regards,
Elias