I am using gem "audited-activerecord", i have a column called "story_html" in a table and it saves the html5 contents.
when i update the "story_html", i get the following error:-
Mysql2::Error: Data too long for column 'story_html' at row 1: UPDATE `mobile_apps` SET `story_html` = ' `story_html` = x'3c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d225554462d38223f3e0d0a2020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202002020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020203c2f706c6973743e', `updated_at` = '2014-12-08 11:26:07' WHERE `mobile_apps`.`id` = 624
Increase the length of the column story_html in your MySQL table mobile_apps to a maximum value that you need. Or change it to text datatype since your content looks very long.
Related
While using [description] varchar NULL for pulling a column from a CSV file to create a table using a powershell script.I am seeing description column shows NULL for rows have values too .
Please let me know how to get all the rows in description column with actual values .
I am using rails and Postgresql. I have a very large table that includes a column called status. From this status column a lot of rows have a value of 1. I want to select a random row based on all rows with a value of 1 in the status column. Each row also has an id and they are sequential.
What is the fastest way to get this random row?
Try to use ActiveRecord solution, e.g :
Model_name.where(status: 1).limit(1).order("RANDOM()")
OR :
Model_name.where(status: 1).order("RANDOM()").first
Hope this helps.
You can play with OFFSET option
SELECT * FROM users WHERE status = 1 OFFSET random()*I LIMIT 1;
The I is the number of rows in table.
I have table with 1500 rows and nearly 10 columns ..
I have imported new data from csv file into another new table, now I want to copy data from this new table to already existing table's 10th column ..
when I try
insert into presentDB (column10) select column1 from importDB
its inserting another 1500 new rows ..
UPDATE presentDB SET column10 = importDB.column1
this thing is throwing an error ..
UPDATE presentDB SET column10 = (SELECT column1 FROM importDB WHERE rowid between 1 and 1500)
gets executed, but copies the first value in column1.importDB to all the cells in present db.
also what will be the query for
copying data in particular range like 100 to 200 from importDB to 500 to 600 in presentDB
can anyone please show a proper direction :) thanks, any help is appreciated :)
You need to have some column that identifies records.
If you have that, you can use a correlated subquery:
UPDATE presentTab
SET column10 = (SELECT column1
FROM importTab
WHERE importTab.ID = presentTab.ID)
On an ADOQuery I've created a String Tfield and set the it's size to 24(from Fields Editor).
When I'm trying to assign to this field a 24 characters length string (qry.fieldbyname('fieldname').asString), only first 20 characters are added. I don't understand why.
How is the query populated with data? If you are doing a select against a table then the column will have the same width as in the table schema. Check how the column is defined in your database.
i have create table like below and inserting the value using insert query from ruby on rails but it's not updating the date value with table. Rest of the field values updating correctly....
give me
Table structure:
CREATE TABLE [Approval] (
[InstallationName] TEXT NULL PRIMARY KEY,
[Approver] TEXT NULL,
[ApprovalCRCdate] DATE NULL,
[ApprovalTime] TIME NULL,
[ApprovalCRC] NUMERIC NULL,
[ApprovalStatus] TEXT NULL
)
insert query:
insert into [Approval] values('_EGONSEOSX0043','dfgdfg','6/6/2011' ,'16:13:14' ,324234 ,'Approved')
maybe you should change the field's type to TEXT?
SQlite's DATE datatype has numeric affinity and you are using / that is not a number.
But I think it should all get inserted since SQLite has 'dynamic typing'