Forum: Ruby on Rails Problems with Rails and Postgres

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
93244c632a214cdcae2629de717d7a4c?d=identicon&s=25 Rafael Roque (rafaelroque)
on 2009-04-16 19:10
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?
67ecd92df094d1e1e571dd199cdd1aac?d=identicon&s=25 Wisccal Wisccal (wisccal)
on 2009-04-18 11:19
Rafael Roque wrote:
> Hi all,
>

Have you looked at the SQL generated in the log directory?
93244c632a214cdcae2629de717d7a4c?d=identicon&s=25 Rafael Roque (rafaelroque)
on 2009-04-20 15:51
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.
53be54e5db4dc58e4980db5a8255621b?d=identicon&s=25 Harold (Guest)
on 2009-04-20 19:25
(Received via mailing list)
What kind of error do you get, exactly?

On Apr 16, 1:10 pm, Rafael Roque <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.