search for: select_value

Displaying 20 results from an estimated 38 matches for "select_value".

2014 Apr 11
2
[LLVMdev] llvm cse optimization
...ign 4 %t7 = alloca [16 x i8], align 16 %add.ptr = getelementptr inbounds i8* %t1, i64 40 %call = call i8* @handle_value(i8* %add.ptr, i32 3) #3 %arraydecay = getelementptr inbounds [8 x i8]* %t3, i64 0, i64 0 %arraydecay1 = getelementptr inbounds [16 x i8]* %t4, i64 0, i64 0 call void @select_value(i8* %arraydecay, i32 1, i32 1, i8* %call, i8* %arraydecay1, i8* null, i32 1, i32 2, i32 1, i8* bitcast ([2 x i32]* @ng0 to i8*), i32 32, i32 1) #3 %call3 = call i8* @handle_value(i8* %add.ptr, i32 3) #3 ; Function Attrs: nounwind readonly declare i8* @handle_value(i8* nocapture, i32) #1 ; Funct...
2005 Oct 17
8
Using active record for SELECT MAX(column) FROM ...
Hi, Is there an easy way of querying an active record for a maximum column value? I need to do queries like: SELECT MAX(salary) FROM employees TIA, Jeroen
2006 May 15
8
set_table_name and self.table_name
...thing... class Contacts < ActiveRecord::Base set_table_name "contact_person" set_primary_key "p_key" def get_next_id ActiveRecord::Base.connection.execute("update #{self.table_name}_seq SET id = id+1") res = ActiveRecord::Base.connection.select_value("SELECT * FROM #{self.table_name}_seq"); res[''id''] end def before_create self.id = get_next_id end end if I replace #{self.table_name} with the hard coded table name, this works well. The error I get is this: NoMethodError: undefined met...
2006 Jan 02
5
How to use MySQL sum() to get total of column?
Easy one: Let''s say I have a table called ''employees'' with a column called salaries, how can I add Employee.salaries_total to the model? Thanks! -- Posted via http://www.ruby-forum.com/.
2006 Apr 30
4
Adding values from a db the rails way?
I have a log table which has a column recording the number of hours worked on a task. So there''ll be multiple lines for a particular task. I want to retrieve the total number of hours worked on a task, so that I can include the information when one views the task details. I can write a sql query to do this easily enough, like "SELECT SUM(hours) AS total FROM tasklog WHERE
2006 Jan 07
8
Using find_by_sql to get the sum of a column
Hello, I was wondering if there was a method in Rails that returns the sum of a column. For example, I have a column called ''score'' and writing a SQL statement such a ''select sum(score) from table_name'' does return the sum of the values in the column. In the past (not too long ago being a newbie), I defined all sorts of methods only to discover that Rails
2006 Feb 25
5
MySQL client ran out of memory
...er.rb:322:in `select'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:175:in `select_one'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/database_statements.rb:16:in `select_value'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:518:in `count_by_sql'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:511:in `count'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/as...
2006 Sep 30
6
generating unique tracking numbers
...use a sequence, but haven''t found a way of doing this with MySQL, so I just increment the max value of the id column. Here''s how I generate a customer number: application.rb: CUSTOMER_BASE = "10000" def next_id(table_name, column) ActiveRecord::Base.connection.select_value("select max(#{column})+1 from #{table_name}") end customer_controller.rb: def create @customer.number = CUSTOMER_BASE.to_i + next_id(''customers'', ''id'').to_i end Have I simply postponed the problem to the day when ids have been re-organized beyo...
2005 Dec 30
9
SELECT MAX
How does one do a SELECT MAX query in rails? I''ve searched and searched and tried lots of things with no luck. I want to implement "SELECT MAX(column_name) from table_name and have it return the maximum value from column_name. I just need to get that one value, not the whole object... Thanks for any ideas... Shelby _______________________________________________ Rails mailing
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 |
2013 Oct 08
0
PostGIS 2.1 rasters available to Rails code: breadcrumbs
...w from rasters, or at least not yet AFAIK. So there''s no way to get pixels out of the raster except one-by-one with an ST_Value query; for a 297x582 array, a nonstarter. Enter PostGIS 2.1 and its lovely lovely ST_DumpValues and ST_SetValues functions. By using the connection''s select_value method, we can return an arbitrary SQL result as a string, in this case a 2D array coded with the PostgreSQL convention of { and } where Ruby uses [ and ]. Likewise, connection.update can take an SQL string, and we can wad a 2D array of values into it with a simple to_s. So here''s the...
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 Apr 20
1
has_many.count not accepting options hash
...;' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_recor d/connection_adapters/mysql_adapter.rb:180:in `select_one'' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_recor d/connection_adapters/abstract/database_statements.rb:16:in `select_value'' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_recor d/calculations.rb:161:in `execute_simple_calculation'' from c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_recor d/calculations.rb:141:in `calculate'' from c:...
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)
2006 Jan 15
0
OS X Rails - Nuby
...sql_adapter.rb:325:in `select'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:175:in `select_one'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/database_statements.rb:16:in `select_value'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:518:in `count_by_sql'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:511:in `count'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:16...
2006 May 06
7
New Ajax and Rails tutorial
Hi, I just published the first version of a small tutorial I''ve written on Ajax and Rails. It is called "How to paginate, sort and search a table with Ajax and Rails" (sorry, I didn''t manage to find a longer title !) and is available at : http://dev.nozav.org/rails_ajax_table.html There is nothing really new in it, it''s rather a compilation and
2007 Oct 08
1
Rails reverses apostrophes
Hi, I am quite new to Ruby on Rails so this might have a very simple answer... My problem gives the following error message when I try to call the count function for an item. Mysql::Error: Unknown column ''TournamentTemplate'' in ''where clause'': SELECT count(*) AS count_all FROM action_logs WHERE (action_logs.loggable_id = 1 AND action_logs.loggable_type =
2006 Jan 15
2
Please help - Rails hanging on mysql connection
.../mysql_adapter.rb:325:in `select'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:175:in `select_one'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/database_statements.rb:16:in `select_value'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:518:in `count_by_sql'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:511:in `count'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:167:...
2007 Jan 18
4
Defining the expected behavior of DatabaseStatements.execute()
It would be very helpful if the core team could define and document the expected behavior of DatabaseStatements.execute(). The implementations appear to vary. Most adapters will return some sort of native result set, SQL Server returns nil and expects a block, DB2 and Sybase return the affected row count. So please, will someone in core explain the expected behavior and can the execute()
2006 Apr 03
4
How to fake composite primary keys?
I know ActiveRecord doesn''t support composite primary keys, but I need to use one, and I need it ASAP. I don''t need any composite foreign keys, luckily; what I have is a table that stores old versions of rows in another table, so the composite key is an id + date stamp. Would someone tell me a hack I can use to support this? -- View this message in context: