sql

All things SQL and JDBC...
isak 2020-06-18T20:12:48.292Z

Since jdbc doesn't support reusing parameters, it seems like it would be smart to just add a declare @x nvarchar(50) = ?; type statements at the top of the queries (if they need to reuse parameters). Anyone see any problems with that?

2020-06-18T21:10:17.292400Z

yes, I would not trust the scoping of those variables

2020-06-18T21:11:51.293200Z

passing in parameters multiple times is nice and simple compared to adding mutable variables that may be connection scoped and passed around through your connection pool

isak 2020-06-18T21:21:34.295700Z

For the db I'm using (SQL Server), there is only one special kind of thing that has connection scope (not normal declares like above). For passing the variable multiple times, I can see it being fine if you can assume it is tiny, but what if you can't? For example, if big json documents are sometimes passed