Sagewire Logo

how to find what the sql excepion was with mysql

3 Message(s) by 2 Author(s) originally posted in ruby programming


From: Junkone Date:   Sunday, October 28, 2007
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


From: Tom Machinski Date:   Sunday, October 28, 2007
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
wrote in message:
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





From: Junkone Date:   Sunday, October 28, 2007
wrote in message:
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],tradeDat=


e,da=ADtaArray[5],dataArray[6])
rescue MysqlException =3D> e
puts e.message
end
-Tom
wrote in message:
> I got an exception
> E:/TradingTools/CODE/ImportTrade.rb:20:in `execute'
> The associated piece of code is
> st=3D 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],tradeDat=


e,da=ADtaArray[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



Next Message: Duplicate elements in array


Blogs related to how to find what the sql excepion was with mysql

25 new messages in 14 topics - digest
I believe DTS is called 'Integration Services' in SQL server 2005 correct? I think I'll need to install it off the cd as I can't find it in it's start group. Thanks for the help. Daf. -- Posted via http://www.ruby-forum.com/. ...

15 new messages in 10 topics - digest
Rewrote SQLite::Database#transaction to use sqlite3-ruby library implementation of transactions. * Model hooks can now be prepended or appended in order to change order of execution. * Enhanced Model.find method to accept block filters. ...

25 new messages in 19 topics - digest
find(:all, options) > end > end > end > end > > Executing user.requests.find_active results in the following SQL: > SELECT * FROM requests WHERE (( requests.user_id = 10 ) AND > ( requests.active = 1 )) AND (requests.user_id = 10) ORDER ...

25 new messages in 17 topics - digest
but this version raises undefined method `respond_via' exception. I am sure it is defined, so it must be my syntax that is to blame. Any suggestions? -- Posted via http://www.ruby-forum.com/. == 2 of 3 == Date: Tues, Oct 23 2007 5:28 am ...

25 new messages in 17 topics - digest
I poked around but didn't > find anything. > > I want to do this for interrupt handling. I'd like to be able to > interrupt long running Python commands. I have a hook which would > throw a C++ exception if an interrupt is detected. ...

24 new messages in 16 topics - digest
In the process, I tried to find some decent > documentation on why Ruby has so many different ways to test for > equality, how they differ and how they should be implemented and used. > > I was unable to find any such documentation, ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional