Skip to content

Instantly share code, notes, and snippets.

@juristr
Last active August 29, 2015 13:59
Show Gist options
  • Save juristr/10451546 to your computer and use it in GitHub Desktop.
Save juristr/10451546 to your computer and use it in GitHub Desktop.
Dapper ODBC QueryMultiple Error
/*
Pieces of code that is being executed
*/
// our variable holding the query
private static string QUERY_ADMISSION_PERSONAL_DATA =
@"
SELECT QCLCOGNO as LastName, QCLNOME as FirstName, QCLLINGUA as PrintLanguage FROM JXPLURIF.QUADCL00F WHERE QCLDONUM=?
SELECT QRIVALORE as Consort FROM JXPLURIF.QUADRI00F WHERE QRIDONUM=? AND QRICODICE='0106'
SELECT QRIVALORE as Children FROM JXPLURIF.QUADRI00F WHERE QRIDONUM=? AND QRICODICE='0107'
SELECT QRIVALORE as DependentChildren FROM JXPLURIF.QUADRI00F WHERE QRIDONUM=? AND QRICODICE='0108'
SELECT QRIVALORE as Family FROM JXPLURIF.QUADRI00F WHERE QRIDONUM=? AND QRICODICE='0109'
SELECT QRIVALORE as DependentFamily FROM JXPLURIF.QUADRI00F WHERE QRIDONUM=? AND QRICODICE='0110'";
...
// our ODBC connection
var conn =new OdbcConnection();
...
// querying
using (var multi = conn.QueryMultiple(QUERY_ADMISSION_PERSONAL_DATA, new DynamicParameters(
new
{
Id = id
})))
{
...
}
// the following exception is thrown
"ERROR [42000] [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0199 - Keyword SELECT not expected. Valid tokens: FOR WITH FETCH ORDER UNION EXCEPT OPTIMIZE.",
@juristr
Copy link
Author

juristr commented Apr 11, 2014

How is QueryMultiple being handled?? The problem apparently is that the underlying ODBC driver doesn't recognize that there are multiple queries but sees them as one and thus doesn't execute because he doesn't expect a select statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment