Forum: Ruby on Rails How to run direct DML (insert or update)

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Glenn C. (Guest)
on 2006-05-19 09:33
I want when the user clicks on a button on the browser
"Perform monthly billing run"  the controller to lanch a sql DML
statment to be called (in the model?) than runs something like

"insert into billing (item, qnt, total_cost, billing_run_timestamp
 select item, qnt, item*cost as total_cost, timestamp
 from services
 where service_end_date is null"

How can I run a DML (insert, update, delete) direct sql statement ?
Richard W. (Guest)
on 2006-05-19 17:30
(Received via mailing list)
On Friday, May 19, 2006, at 7:33 AM, Glenn C. wrote:
>Posted via
>Rails mailing list

Item.connection.execute("select count(*) from items")

or generally:

Glenn C. (Guest)
on 2006-05-22 05:40
Thanks Richard it works perfectly
This topic is locked and can not be replied to.