Hello, I am having a problem seeing if a SQL statement worked or not... I know I''m not really doing my SQL statement the proper ''RoR'' way, but I don''t think that is the problem. My code is supposed to query the database where the displayname = the posted legalname. If no results are returned, then do the same query, but where displayname = the posted othername. The problem is when it evaluates if @compare_bes == nil.... even if it doesn''t return results, it won''t execute the stuff within the IF statement. @compare_bes = Bes.connection.select_all(" SELECT * FROM bes WHERE bes.bes_displayname = ''#{params[:legalname]}''") if @compare_bes == nil <--- THIS IS THE PROBLEM @compare_bes = Bes.connection.select_all(" SELECT * FROM bes WHERE bes.bes_displayname = ''#{params[:othername]}''") end So I am not sure what do use to evaluate if the first query is empty. I tried @compare_bes == '''', == "", unless @compare_bes, unless @compare_bes != nil, etc... Does anybody know how to do this? Any help is appreciated! Thanks, - Jeff Miller -- 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 -~----------~----~----~----~------~----~------~--~---
ESPNDev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Mar-13 22:43 UTC
Re: Can''t seem to Compare MySQL Statement
Have you tried: if @compare_bes.empty? On Mar 13, 3:31 pm, Jeff Miller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello, > I am having a problem seeing if a SQL statement worked or not... I know > I''m not really doing my SQL statement the proper ''RoR'' way, but I don''t > think that is the problem. My code is supposed to query the database > where the displayname = the posted legalname. If no results are > returned, then do the same query, but where displayname = the posted > othername. The problem is when it evaluates if @compare_bes == nil.... > even if it doesn''t return results, it won''t execute the stuff within the > IF statement. > > @compare_bes = Bes.connection.select_all(" > SELECT * > FROM bes > WHERE > bes.bes_displayname = ''#{params[:legalname]}''") > > if @compare_bes == nil <--- THIS IS THE PROBLEM > @compare_bes = Bes.connection.select_all(" > SELECT * > FROM bes > WHERE > bes.bes_displayname = ''#{params[:othername]}''") > > end > > So I am not sure what do use to evaluate if the first query is empty. I > tried @compare_bes == '''', == "", unless @compare_bes, unless > @compare_bes != nil, etc... > > Does anybody know how to do this? > > Any help is appreciated! > > Thanks, > - Jeff Miller > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Have you tried: @compare_bes.empty? On Mar 13, 5:31 pm, Jeff Miller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello, > I am having a problem seeing if a SQL statement worked or not... I know > I''m not really doing my SQL statement the proper ''RoR'' way, but I don''t > think that is the problem. My code is supposed to query the database > where the displayname = the posted legalname. If no results are > returned, then do the same query, but where displayname = the posted > othername. The problem is when it evaluates if @compare_bes == nil.... > even if it doesn''t return results, it won''t execute the stuff within the > IF statement. > > @compare_bes = Bes.connection.select_all(" > SELECT * > FROM bes > WHERE > bes.bes_displayname = ''#{params[:legalname]}''") > > if @compare_bes == nil <--- THIS IS THE PROBLEM > @compare_bes = Bes.connection.select_all(" > SELECT * > FROM bes > WHERE > bes.bes_displayname = ''#{params[:othername]}''") > > end > > So I am not sure what do use to evaluate if the first query is empty. I > tried @compare_bes == '''', == "", unless @compare_bes, unless > @compare_bes != nil, etc... > > Does anybody know how to do this? > > Any help is appreciated! > > Thanks, > - Jeff Miller > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
that worked perfectly! I have to remember that. Thanks!! -- 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 -~----------~----~----~----~------~----~------~--~---
ESPNDev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Mar-13 23:15 UTC
Re: Can''t seem to Compare MySQL Statement
No problem! On Mar 13, 4:11 pm, Jeff Miller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> that worked perfectly! I have to remember that. Thanks!! > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---