Re: T-SQL Error Message Capture

2018-06-08 Thread Jeremy Evans
On Thursday, June 7, 2018 at 7:09:36 PM UTC-7, ELMER IBAYAN wrote:
>
> Hi Jeremy,
>
> We are using JDBC:MSSQL driver and I realise there's a similar question 
> posted here at StackOverflow 
> 
>  
> :  
> I think the way it's getting it from JDBC is thru Statement.getWarnings() 
> like this:
>
> Statement stmt = ...;
> stmt.execute("some_procedure");
>
> SQLWarning warning = stmt.getWarnings();
> while (warning != null){
>System.out.println(warning.getMessage());
>warning = warning.getNextWarning();}
>
>
> I am not sure if there's an equivalent method in Sequel that we can use in 
> order to implement capturing of this warning message. In my application, I 
> am using "fetch" command which returns single "result_set" all the time. 
>

There currently isn't a method in Sequel to get these warnings.  Based on 
the fact that nobody has requested this feature in 10 years, it seems like 
it isn't needed often, and as such it doesn't make sense to include support 
in the jdbc adapter itself, though I'd be open to supporting it via an 
extension that ships with Sequel.  If you'd like to see that, please submit 
a pull request that adds such an extension along with appropriate 
integration tests.

My guess is the easiest way to implement this is to override 
Sequel::JDBC::Database#statement, but you'll have to decide on an 
appropriate API.  It would probably be best to be able to set a callable 
object that gets called with all JDBC warning messages, as that is the most 
flexible way to handle it.
 

> Additional question I have is that is there a way to detect presence of 
> multiple result set? 
>

No. Having a dataset return multiple result sets is not supported by Sequel.

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 sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.


Re: T-SQL Error Message Capture

2018-06-07 Thread ELMER IBAYAN
Hi Jeremy,

We are using JDBC:MSSQL driver and I realise there's a similar question 
posted here at StackOverflow 

 
:  
I think the way it's getting it from JDBC is thru Statement.getWarnings() 
like this:

Statement stmt = ...;
stmt.execute("some_procedure");

SQLWarning warning = stmt.getWarnings();
while (warning != null){
   System.out.println(warning.getMessage());
   warning = warning.getNextWarning();}


I am not sure if there's an equivalent method in Sequel that we can use in 
order to implement capturing of this warning message. In my application, I 
am using "fetch" command which returns single "result_set" all the time. 

Additional question I have is that is there a way to detect presence of 
multiple result set? 

Thank you so much for your reply.

Regards,
elmer



On Monday, 4 June 2018 11:26:03 UTC+10, Jeremy Evans wrote:
>
> On Sunday, June 3, 2018 at 5:40:57 PM UTC-7, ELMER IBAYAN wrote:
>>
>> Hi Jeremy,
>>
>> Thank you for your reply. I really appreciate the help that your team can 
>> extend. 
>> Maybe I didn't really explain in detail what I need. I would like to grab 
>> the whole message returned when calling a stored procedure which shows up 
>> in the Message Tab in T-SQL/SQL Server output which typically would log 
>> something similar below:
>>
>> *Msg 8134, Level 16, State 1, Line 56*
>> *Divide by zero error encountered.*
>>
>> If I wanted to capture whatever message will be written, is there a 
>> method from 'sequel gem' that I can use to grab the whole thing? Currently, 
>> I am detecting the result set, if it contains return_code to be 0, then I 
>> consider them as completed successfully. However, there are cases wherein, 
>> it doesn't return an exception since the result set has return_code 0, but 
>> there are error in the "messages" tab output. 
>>
>> Any advice on approaching this problem would be very much appreciated.
>>
>
> First, you'll need to figure out how to get this information from the 
> tiny_tds driver (or whatever driver you are using).  If you are successful 
> doing that, then report back here with how to do that, and I can probably 
> help with getting access to the information with Sequel.
>
> 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 sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.


Re: T-SQL Error Message Capture

2018-06-03 Thread Jeremy Evans
On Sunday, June 3, 2018 at 5:40:57 PM UTC-7, ELMER IBAYAN wrote:
>
> Hi Jeremy,
>
> Thank you for your reply. I really appreciate the help that your team can 
> extend. 
> Maybe I didn't really explain in detail what I need. I would like to grab 
> the whole message returned when calling a stored procedure which shows up 
> in the Message Tab in T-SQL/SQL Server output which typically would log 
> something similar below:
>
> *Msg 8134, Level 16, State 1, Line 56*
> *Divide by zero error encountered.*
>
> If I wanted to capture whatever message will be written, is there a method 
> from 'sequel gem' that I can use to grab the whole thing? Currently, I am 
> detecting the result set, if it contains return_code to be 0, then I 
> consider them as completed successfully. However, there are cases wherein, 
> it doesn't return an exception since the result set has return_code 0, but 
> there are error in the "messages" tab output. 
>
> Any advice on approaching this problem would be very much appreciated.
>

First, you'll need to figure out how to get this information from the 
tiny_tds driver (or whatever driver you are using).  If you are successful 
doing that, then report back here with how to do that, and I can probably 
help with getting access to the information with Sequel.

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 sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.


Re: T-SQL Error Message Capture

2018-06-03 Thread ELMER IBAYAN
Hi Jeremy,

Thank you for your reply. I really appreciate the help that your team can 
extend. 
Maybe I didn't really explain in detail what I need. I would like to grab 
the whole message returned when calling a stored procedure which shows up 
in the Message Tab in T-SQL/SQL Server output which typically would log 
something similar below:

*Msg 8134, Level 16, State 1, Line 56*
*Divide by zero error encountered.*

If I wanted to capture whatever message will be written, is there a method 
from 'sequel gem' that I can use to grab the whole thing? Currently, I am 
detecting the result set, if it contains return_code to be 0, then I 
consider them as completed successfully. However, there are cases wherein, 
it doesn't return an exception since the result set has return_code 0, but 
there are error in the "messages" tab output. 

Any advice on approaching this problem would be very much appreciated.

Regards,
elmer

On Friday, 1 June 2018 14:20:37 UTC+10, Jeremy Evans wrote:
>
> On Thursday, May 31, 2018 at 6:35:56 PM UTC-7, ELMER IBAYAN wrote:
>>
>> Hello sequel team,
>>
>> I am trying to capture error messages based on different scenarios when 
>> calling stored procedures on T-SQL. I am able to grab result_set properly 
>> when return_code 0 as the first row for normal successful case. However, 
>> there are cases wherein, result set returns 0 return_code as well even if 
>> it's a valid error. Since most of these valid errors have corresponding 
>> error message, how can I grab these error_message using ruby? 
>>
>> On another scenario where it raises an exception error, I can get the 
>> "wrapped_exception.error_code". My second question is still how to get or 
>> is there any method available to grab the rest of the message as a whole or 
>> even by component such as "error_code" from wrapped_exception? 
>>
>
> The wrapped_exception is generally the exception raised by the database 
> driver.  To get any lower level error handling, you would have to call 
> methods on that object, and the methods supported are going to depend on 
> the database driver in use.  Refer to the database driver documentation 
> and/or source code for which methods are available.
>
> 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 sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.


Re: T-SQL Error Message Capture

2018-05-31 Thread Jeremy Evans
On Thursday, May 31, 2018 at 6:35:56 PM UTC-7, ELMER IBAYAN wrote:
>
> Hello sequel team,
>
> I am trying to capture error messages based on different scenarios when 
> calling stored procedures on T-SQL. I am able to grab result_set properly 
> when return_code 0 as the first row for normal successful case. However, 
> there are cases wherein, result set returns 0 return_code as well even if 
> it's a valid error. Since most of these valid errors have corresponding 
> error message, how can I grab these error_message using ruby? 
>
> On another scenario where it raises an exception error, I can get the 
> "wrapped_exception.error_code". My second question is still how to get or 
> is there any method available to grab the rest of the message as a whole or 
> even by component such as "error_code" from wrapped_exception? 
>

The wrapped_exception is generally the exception raised by the database 
driver.  To get any lower level error handling, you would have to call 
methods on that object, and the methods supported are going to depend on 
the database driver in use.  Refer to the database driver documentation 
and/or source code for which methods are available.

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 sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.