[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

how to find what the sql excepion was with mysql

Junkone

10/28/2007 2:11:00 PM

I got an exception
E:/TradingTools/CODE/ImportTrade.rb:20:in `execute'

The associated piece of code is
st= dbConn.prepare("insert into raw_data

(SYMBOL,ACTION,SIZE,PRICE,DATE_TIME_OF_TRADE ,EXECUTION,ACCOUNT_ID)
VALUES(?,?,?,?,?,?,?)")
st.execute(dataArray[0],dataArray[1],dataArray[2],dataArray[3],tradeDate,dataArray[5],dataArray[6])
st.close

How do i find out what the exception details were that was triggered
at st.execute in this case.
any assistance will be appreciated

2 Answers

Tom Machinski

10/28/2007 4:22:00 PM

0

Assuming the exception object is e, you can check out e.

Exceptions and rescuing them works like this (assuming you want to
st.execute throws a MysqlException):

begin
st.execute(dataArray[0],dataArray[1],dataArray[2],dataArray[3],tradeDate,dataArray[5],dataArray[6])
rescue MysqlException => e
puts e.message
end

-Tom



On 10/28/07, Junkone <junkone1@gmail.com> wrote:
> I got an exception
> E:/TradingTools/CODE/ImportTrade.rb:20:in `execute'
>
> The associated piece of code is
> st= dbConn.prepare("insert into raw_data
>
> (SYMBOL,ACTION,SIZE,PRICE,DATE_TIME_OF_TRADE ,EXECUTION,ACCOUNT_ID)
> VALUES(?,?,?,?,?,?,?)")
> st.execute(dataArray[0],dataArray[1],dataArray[2],dataArray[3],tradeDate,dataArray[5],dataArray[6])
> st.close
>
> How do i find out what the exception details were that was triggered
> at st.execute in this case.
> any assistance will be appreciated
>
>
>

Junkone

10/28/2007 6:10:00 PM

0

On Oct 28, 12:21 pm, "Tom Machinski" <tom.machin...@gmail.com> wrote:
> Assuming the exception object is e, you can check out e.
>
> Exceptions and rescuing them works like this (assuming you want to
> st.execute throws a MysqlException):
>
> begin
> st.execute(dataArray[0],dataArray[1],dataArray[2],dataArray[3],tradeDate,da?taArray[5],dataArray[6])
> rescue MysqlException => e
> puts e.message
> end
>
> -Tom
>
> On 10/28/07, Junkone <junko...@gmail.com> wrote:
>
>
>
> > I got an exception
> > E:/TradingTools/CODE/ImportTrade.rb:20:in `execute'
>
> > The associated piece of code is
> > st= dbConn.prepare("insert into raw_data
>
> > (SYMBOL,ACTION,SIZE,PRICE,DATE_TIME_OF_TRADE ,EXECUTION,ACCOUNT_ID)
> > VALUES(?,?,?,?,?,?,?)")
> > st.execute(dataArray[0],dataArray[1],dataArray[2],dataArray[3],tradeDate,da?taArray[5],dataArray[6])
> > st.close
>
> > How do i find out what the exception details were that was triggered
> > at st.execute in this case.
> > any assistance will be appreciated- Hide quoted text -
>
> - Show quoted text

Great. It works. Can i get it to print the sql that was executed that
caused the error. becaues i am using a prepared statement