Re: Named vs numbered SQL parameters
Peter Bex 19 Sep 2019 07:20 UTC
On Wed, Sep 18, 2019 at 06:36:08PM -0400, John Cowan wrote:
> SQLite, My+Maria, Oracle, and SQL Server all support named parameters, some
> with colons, some with @ signs (: does have meaning in SQL array slices, @
> does not). Postgres has no support at present.
Are you sure? From what I can gather, MySQL/MariaDB only supports
question marks:
https://dev.mysql.com/doc/refman/5.7/en/prepare.html
Indeed, SQLite has several syntaxes for named params:
https://sqlite.org/c3ref/bind_blob.html
Microsoft SQL only seems to support question marks in arbitrary
statements:
https://docs.microsoft.com/en-us/sql/relational-databases/native-client-odbc-queries/using-statement-parameters?view=sql-server-2017
AFAICT, stored procedures can be called with parameters by name:
https://docs.microsoft.com/en-us/sql/odbc/reference/develop-app/binding-parameters-by-name-named-parameters?view=sql-server-2017
I find it hard to find anything definitive regarding Oracle.
> But if you take up my suggestion for a fairly simplistic/agnostic SQL DSL,
> you don't need parameters, named or nameless.
I emphatically disagree. IMO, the DSL is another layer that lies
on top of the underlying DBI. The DBI layer *must* have a way to
separate SQL queries from parameters.
Cheers,
Peter