Hi all, i have a method that I use in the ''after_save'' that is implemented as follows: def verify a =11674 x = self.aui_codigo reinc =AutoInfracao.find_by_sql("select age((select aui_data_lav from tb_aui_auto_infracao where aui_codigo=#{a}), (select max(aui_data_lav)from tb_aui_auto_infracao where aui_codigo in(select a.aui_codigo from tb_aur_auto_inf_regular a,tb_iau_itens_auto i where a.for_cod =(select for_cod from tb_aur_auto_inf_regular where aui_codigo=#{a}) and a.lir_codigo=(select lir_codigo from tb_aur_auto_inf_regular where aui_codigo = #{a}) and i.inf_codigo (select inf_codigo from tb_iau_itens_auto where aui_codigo = #{a}) and a.aui_codigo<>#{a} and a.aui_codigo = i.aui_codigo)))") print reinc[0].age end the ''a'' and the ''x'' variables have the same value(11674) and the same type(FixNum).Curiously,I can run my query using the ''a'' variable,but I cannot run it using the ''x'' variable.What am I doing wrong? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rafael Roque wrote:> Hi all, >Have you looked at the SQL generated in the log directory? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Wisccal Wisccal wrote:> Rafael Roque wrote: >> Hi all, >> > > Have you looked at the SQL generated in the log directory?Yep.. If I grab the sql in the output directly in the pgAdmin and execute it,I get the correct result. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
What kind of error do you get, exactly? On Apr 16, 1:10 pm, Rafael Roque <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi all, > > i have a method that I use in the ''after_save'' that is implemented as > follows: > > def verify > a =11674 > x = self.aui_codigo > > reinc =AutoInfracao.find_by_sql("select age((select aui_data_lav > from tb_aui_auto_infracao where aui_codigo=#{a}), > (select max(aui_data_lav)from tb_aui_auto_infracao where aui_codigo > in(select a.aui_codigo from tb_aur_auto_inf_regular a,tb_iau_itens_auto > i where a.for_cod =(select for_cod from tb_aur_auto_inf_regular where > aui_codigo=#{a}) and a.lir_codigo=(select lir_codigo from > tb_aur_auto_inf_regular where aui_codigo = #{a}) and i.inf_codigo > (select inf_codigo from tb_iau_itens_auto where aui_codigo = #{a}) and > a.aui_codigo<>#{a} and a.aui_codigo = i.aui_codigo)))") > > print reinc[0].age > end > > the ''a'' and the ''x'' variables have the same value(11674) and the same > type(FixNum).Curiously,I can run my query using the ''a'' variable,but I > cannot run it using the ''x'' variable.What am I doing wrong? > -- > Posted viahttp://www.ruby-forum.com/.