search for: select_all

Displaying 20 results from an estimated 89 matches for "select_all".

2007 Aug 14
1
find_by_sql vs connection.select_all
...) The query that is written to the log is: SELECT SUM(updated_on - created_on) AS total from signups Like I said before, if I take that query to the mySQL console, I get the expected result, however the result to the view is simply # NOW, if take the query and put it in with: Signup.connection.select_all("SELECT SUM(updated_on - created_on) AS total from signups") I get the expected result to the view and the same SQL code is written to the log What is the difference then in find_by_sql and connection.select_all My initial guess is that find_by_sql is expecting a normal find(:all) base...
2005 Apr 27
4
has_many syntax
Hi all, I have the following inside of an AR class definition: relationships=ActiveRecord::Base.connection.select_all(my_relationships_sql) relationships.each do |relationship| has_many RelatedItems, :class_name => relationship[''RelatedClass''], :foreign_key => relationship[''ForeignKey''] end This kind of works, but how can I assign the name of the relationships? my_rela...
2006 May 15
2
retrieving hashes key & values (ASAP)
Hi, I want to retrieve the set of key & values which returns from a stored procedure : connection.select_all "exec common.dbo.scr_lookupric ''AAP.N'' ". The results i want to display in a view screen call result.rhtml. Please help me out ASAP. Thanks in advance. joshua... -- Posted via http://www.ruby-forum.com/.
2006 Jul 05
10
Scalable alternative to #find_all
Is there any scalable alternative to iterating all the records of a certain model? #find_all seems to load everything into memory. With 500.000 records it will be a swap storm. Pedro.
2008 May 30
9
find_by_sql without a model? how to do this?
Hi, I''d like to do a "find_by_sql" without a model (e.g. <model name>.find_by_sql("...")) as the results I get back are a once off special, and I''m happy to handle them as an array. How do I do this? "ActiveRecord::Base.find_by_sql(...)" does not seem to work? Background - At the moment I''m doing within a model <model_name>,
2006 Jun 21
2
raw sql and columns order
Hi, I''ve a model with the following method: def self.run(sql) return connection.select_all(sql) end so, the value returned is an array of hashes... the problen is that the sql command: "select name, id from table" and select id,name from table" returns the columns in the same order (name, id). And in my view, I need to keep the order of the SQL command. (Don'&...
2006 Jun 23
1
''Series'' Pluralization
...n_adapters/mysql_adapter.rb:185:in `execute'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/mysql_adapter.rb:337:in `select'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/mysql_adapter.rb:176:in `select_all'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:390:in `find_by_sql'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:924:in `find_every'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:...
2007 Jan 25
3
Sum multiple columns individually
Can you sum a few columns at a time? I tried x =Calc.find(:all, :select => "sum(amt1) amt1, sum(amt2) amt2" :conditions => ["where date > ?", date] ) The sql seems to function properly, but I wasn''t able to grab the values. These just failed x.amt1 x.send("amt1") I tried changing up the query to use sum(amt1) as amt1 sum(amt1)
2008 Mar 07
3
Boolean circles..
...adapter.rb:132:in `execute'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/sqlite_adapter.rb:256:in `select'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:55:in `select_all'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:532:in `find_by_sql'' from /Library/Ru...
2009 Apr 11
6
Inserting data from 1 table to another by using find_by_sql
...ect when you didn''t expect it! The error occurred while evaluating nil.all_hashes vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:482:in `select'' vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'' vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:53:in `select_all'' vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:74:in `cache_sql'' vendor/rails/activerecord/lib/active_r...
2011 Jan 06
4
Not able to insert value in rails console
...ib/ruby/gems/1.9.1/gems/activerecord-sqlserver-adapter-3.0 .5/lib/active_record/connection_adapters/sqlserver/database_statements.rb:193:in `select'' from c:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_reco rd/connection_adapters/abstract/database_statements.rb:7:in `select_all'' from c:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_reco rd/connection_adapters/abstract/query_cache.rb:56:in `select_all'' from c:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_reco rd/base.rb:467:in `find_by_sql'' fro...
2006 Aug 17
6
NameError in AdminController#index building scaffold
...uot;Cache-Control"=>"no-cache"} I have tried building the scaffold with users and admin instead of Users and Admin, but it''s still not working! Also, I verified MySQL connectivity from ruby server to the database by doing the following: ActiveRecord::Base.connection.select_all(''desc users'') => [{"Extra"=>"auto_increment", "Default"=>nil, "Null"=>"NO", "Type"=>"int(11)", "Field"=>"user_id", "Key"=>"PRI"}, {"Extra"=...
2005 Dec 18
1
Multiple selection....
Hi, I have a table with a paginator and each row displays its own checkbox. I want to be able to offer actions like select_all/deselect_all/select_partial. The problem how does on record user actions so that the form is correctly posted once the user hits submit ? Can anyone point me out to an elegant solution to this common problem ? Code or article would be great !! Many Thanks... -- Posted via http://www.rub...
2008 Mar 20
0
Mixing stored procedure call with RoR db calls in the same function gives errors
..._adapter.rb ConnectionAdapters::MysqlAdapter.new(mysql, logger, [host, username, password, database, port, socket], config) to ConnectionAdapters::MysqlAdapter.new(mysql, logger, [host, username, password, database, port, socket, 65536 + 131072], config) as recommended. However I use connection.select_all("call spName(params)") to execute my stored proc instead of using select_sp as defined and recommended in the abovementioned article - partly because select_all seemed to work fine and the article above was written for some older version of rails as the lines numbers where changes were to...
2011 Jan 15
0
NoMethodError: undefined method `more_results' for #<Mysql>
...;Mysql> from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/mysql_adapter.rb:623:in `select'' from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all'' from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/query_cache.rb:56:in `select_all'' from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/base.rb:467:in `find_by_sql'' from /L...
2006 Jan 11
2
How to execute an SQL statement in rails?
Hello, This is probably a silly question but looking at "api.rubyonrails.org", I can''t seem to figure out which method I should be using ... I want to execute an sql statement, like "truncate table BLAH" from within one of my rails app ... What''s the "right" way to do this? Thanks, /B -- Bruno Mattarollo <bruno.mattarollo@gmail.com>
2006 Jan 10
1
sql server freetds/odbc question
...eTDS][SQL Server]The column ''name'' was specified multiple times for ''tally''.): /usr/lib/site_ruby/1.8/DBD/ODBC/ODBC.rb:168:in `execute'' /usr/lib/site_ruby/1.8/dbi/dbi.rb:640:in `execute'' /usr/lib/site_ruby/1.8/dbi/dbi.rb:671:in `select_all'' /vendor/rails/activerecord/lib/active_record/connection_adapters/ sqlserver_adapter.rb:354:in `add_limit_offset!'' /vendor/rails/activerecord/lib/active_record/base.rb:931:in `add_limit!'' /vendor/rails/activerecord/lib/active_record/base.rb:924:in `con...
2009 Mar 06
2
ActiveRecord::Base
Why this doesn''t work? ActiveRecord::Base.connection.execute("\\d") ? I use PostgreSQL server and this should be command to get list of all tables within a database. Is there a problem with privileges or PGSQL driver for rails doesn''t support it? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message
2006 Nov 12
2
Model-less SQL results
I''m trying to get some stats from my database about my model, and I''m not sure how to go about it. If I have a model ''foo'' that has an attribute ''color'' and I want to get some counts on this I could use the sql: SELECT color, COUNT(*) AS count FROM items GROUP BY status which would return something like: +--------+-------+ | color |
2006 Aug 15
2
has_many + finder_sql & :include
...pter.rb:120:in `log'' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/sqlserver_adapter.rb:485:in `select'' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/sqlserver_adapter.rb:233:in `select_all'' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/associations.rb:1110:in `select_all_rows'' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/associations.rb:975:in `find_with_associations'' from c:/ruby/lib/ruby/gem...