From: Todd Benson Date: 2008-05-30T09:04:14+09:00 Subject: Re: How do i replace actual value in the query with variables? On Thu, May 29, 2008 at 6:09 PM, Ting Chang wrote: > I try to set up a loop to put the data in the array into the oracle > data base by iteration. > Thus I put the variable into the sql query. I know this is no correct > for dynamic querying, > Can you give me some advise about how to do dynamic querying in ruby and > oracle? > > Here is my wrong example. I hope this help you understand my question. I > really > appreciate your help..Thank you so much!! > ---------------------------------------------------------------------------------------------------- > for q in 0..4 > s = Float(q) > > conn.exec( 'UPDATE SCH_EVENT SET P_ID = 2444334 where RANK= s AND > playlist_id=432') > > end > ------------------------------------------------------------------------------------------------------ > > Best Regards, > Erick You can expand within double quotes using "#{my_var}", so maybe something like... conn.exec( "UPDATE SCH_EVENT SET P_ID = 2444334 where RANK = #{s} AND playlist_id=432") Usually, capitalization in a SQL statement is reserved for keywords, but everyone has their own style. Todd