Closed lukaseder closed 3 years ago
Thanks for the fix. I agree that letting the server validate these variables is a pragmatic approach that should work well.
Snapshots are available from oss.sonatype.org for 0.8.6 and 0.9.0 versions.
I can confirm, jOOQ's INSERT/UPDATE/DELETE .. RETURNING
emulations now work correctly on SQL Server
Bug Report
Versions
Current Behavior
This seems to be perfectly valid in SQL Server:
Yet, I'm getting:
Expected behavior/code
The driver should be able to distinguish between local variables and bind parameters. JDBC doesn't have this problem as JDBC uses
?
for parameter markers.Possible Solution
A workaround is to avoid bind variables as soon as local variables are being used:
It's hard to say how else this could be solved in the driver. A heuristic would regex-search for
declare\s+@(\w+)
and exclude those names from being required as bind variables. An actual parser would be even better, but not really practical, given T-SQL's vast syntax.Also, this shows that a solution shouldn't just stop requiring
@i
from being bound, but even prevent it from being bound. This is also illegal in SQL Server:Leading to: