2 ms·
I have to agree with your assessment of SQL APIs. Funny how not a single one seems to have been designed by someone who'd seen printf & scanf. In their defens
by jklowden 10y ago
I have to agree with your assessment of SQL APIs. Funny how not a single one seems to have been designed by someone who'd seen printf & scanf.
In their defense, your obvious use case is evidence of a database design problem and shouldn't be in the API. The thing `Name` is in should itself have a name or type or class or group or something, capturing the reason foo, bar, and baz go together. Then the SQL is
SELECT * FROM MyTable WHERE NameType = 'foo_group';
For the ad hoc alternative, you need an easy way to insert your array into a temporary table (again, API deficiency) or supply a table parameter, so you can do
INSERT INTO #T values -- [your array here]
SELECT * FROM MyTable WHERE Name IN (SELECT t from #t);
or
SELECT * FROM MyTable WHERE Name IN ?; -- vaporware SQL syntax
- Pxtl 10y agoThe table-valued approach is always my preferred option, but often that's a where bad APIs become a nuisance. I mean, look at all this boilerplate: http://stackoverflow.com/questions/10409576/pass-table-valued-parameter-using-ado-net http://stackoverflow.com/questions/10409576/pass-table-value...