samedi 27 juin 2015

Insight.Database procedure call using ODBC fails

I am using the ODBC provider to connect to a iSeries DB2 database. All the following calls work great!:

List<Beer> beers = conn.QuerySql<Beer>("SELECT * FROM Beer WHERE Typee = @Typee", new { Typee = "IPA" }).ToList();

var beer = new Beer { ID=41,Typee="Medium", Description = "From dotNet Neither light or dark"};

conn.ExecuteSql("INSERT INTO Beer VALUES (@ID, @Typee, @Description)", new { ID = 4, Typee = "Medium", Description = "From dotNet Neither light or dark" });

conn.ExecuteSql("CALL INSERTBEER (@ID, @Typee, @Description) ", new { ID = 4, Typee = "MediumOD", Description = "From dotNet Neither light or dark" });

conn.ExecuteSql("INSERT INTO Beer VALUES (@ID, @Typee, @Description)", beer);

Which is awesome, I am really digging this micro-ORM. But I dont want to type out the LHS parameters in the call to the InsertBeer stored procedure. I believe that is the type of plumbing work that can be avoided with the Execute() procedure. Sadly, these calls DONT work:

conn.Execute("INSERTBEER", beer);

I also tried:

conn.Execute("insertbeer", new Beer {ID = 4, Typee = "Medium", Description = "From dotNet Neither light or dark"}, CommandType.StoredProcedure, true, Int32.MaxValue, null, beer);   

The error I am getting is:

{"ERROR [42000] [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0104 - Token INSERTBEER was not valid. Valid tokens: ( CL END GET SET CALL DROP FREE HOLD LOCK OPEN WITH."}

Any ideas greatly appreciated!

Aucun commentaire:

Enregistrer un commentaire