[
https://issues.apache.org/jira/browse/CALCITE-1671?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15898241#comment-15898241
]
Francis Chuang commented on CALCITE-1671:
-----------------------------------------
The spec is quite "loose" as it defers to the underlying databases for
implementation. Any behavior it defines pertains to the client only. For Go 1.8
(where named parameteres are supported), the changes are here:
https://docs.google.com/document/d/1F778e7ZSNiSmbju3jsEWzShcb8lIO4kDyfKDNm4PNd8/edit
- It makes no recommendations for how parameters are embedded in SQL nor what
characters are allowed. Go has built in unicode support, so any character can
be used.
- It makes no recommendations for whether a parameter can be used more than
once.
- Parameters have both an ordinal and named value. If it has a name, then we
only use the name for parameter substitution. If the parameter is unnamed, then
use the ordinal position for substitution.
In terms of named bind parameters, driver implementers should:
- Use the `sql.Named("parameter", value)" when working with named parameters.
For example, as a user of the database/sql package and a given driver, you
would write the following:
{code}
db.ExecContext(ctx, `
delete from Invoice
where
TimeCreated < @end
and TimeCreated >= @start;`,
sql.Named("start", startTime),
sql.Named("end", endTime),
)
{code}
- Defer the placeholder value to the driver or database, for example using `?`
for ordinal values.
- If both named and ordinal values are used in a statement, named parameters
should be bound to named values and ordinal parameters should use ordinal
values.
- Drivers must add any symbol prefix to named parameters. The database/sql will
pass in something like "ID" or "Name" and the driver shoudl prepend the symbol
if required: ":NAME" or "@NAME".
- If the database does not support named parameters, return an error if they
are used.
> Support for named bind parameters
> ---------------------------------
>
> Key: CALCITE-1671
> URL: https://issues.apache.org/jira/browse/CALCITE-1671
> Project: Calcite
> Issue Type: New Feature
> Reporter: Francis Chuang
> Assignee: Julian Hyde
> Priority: Minor
>
> As discussed on the mailing list, there is some interest in supporting named
> bind parameters:
> {code}
> SELECT * FROM my_table WHERE my_column > :parameter1 AND mycolumn2 >
> :parameter2
> {code}
> Will mixing of named and unnamed parameters be allowed?
> {code}
> SELECT * FROM my_table WHERE my_column > :parameter1 AND mycolumn2 > ? AND
> mycolumn3 > :parameter3
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)