On Thursday, June 6, 2019 at 5:40:33 AM UTC-7, Rama Musidipalli wrote:
>
>
> I am new to Ruby... Please pardon me for any incorrect terminology..
>
>
> Issue: DB["DELETE..."] ran using tinyTDS is returning empty array whereas
> thru JDBC sybase adapter is not returning this empty array thus resulting
> in failure of ".all" method
>
>
>
> Details:
>
> We have existing Ruby code that is using tinyTDS and doing all DB
> operations with DB[ ] in a generic interface. And then running "all" method
> as below. (yes... for DELETE, SELECT, Stored Procedures etc).
>
> data = @db["#{query}"]
>
> output = data.all
>
Well, that's a bad idea and a misuse of the API. It's fine if you limit
that to queries that return rows, but when you use it for other operations,
you are off in undefined/ adapter-dependent behavior.
> We changed the "adapter" to JDBC. Everything working fine but "all" is
> throwing exception "Java::JavaSql::SQLException: The executeQuery method
> must return a result set." when a stored procedure or DML statements are
> ran. Whereas working when SELECT queries are ran...
>
> Rightnow used some hack like i.e., looking for the above exception and in
> rescue returning empty array but it is not sounding clean.
>
> Could you suggest any solution for this as we want to follow same generic
> interface approach and want to return empty array in case stored proc
> doesn't return result set.
>
You should restructure your interface so that for delete/update/insert
queries, you call delete/update/insert on the dataset. You can still
return [] to the caller in those cases.
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/cecc86bf-0c65-4a5a-b112-6870a4de1ca9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.