2017-09-18 12 views
0

レール:エラー:列MySQLの範囲値のうち、私は、SQLテーブル持っ

-- Table structure for rb_amazon_daily 
-- ---------------------------- 
DROP TABLE IF EXISTS `rb_amazon_daily`; 
CREATE TABLE `rb_amazon_daily` (
    `id` int(11) NOT NULL AUTO_INCREMENT, 
    `date` date DEFAULT NULL, 
    `book_title` varchar(255) DEFAULT NULL, 
    `marketplace` varchar(255) DEFAULT NULL, 
    `amazon_kdp_avg_list_price` decimal(12,10) DEFAULT NULL, 
    `amazon_kdp_royalty_type` varchar(255) DEFAULT NULL, 
    `amazon_kdp_revenue_in_usd` decimal(13,13) DEFAULT NULL, 
    `amazon_kdp_royalty_in_usd` decimal(13,13) DEFAULT NULL, 
    `amazon_kdp_paid_downloads` int(11) DEFAULT NULL, 
    `amazon_kdp_free_downloads` int(11) DEFAULT NULL, 
    `amazon_ku_pages_read` int(11) DEFAULT NULL, 
    `amazon_ku_revenue_in_usd` decimal(12,10) DEFAULT NULL, 
    `create_space_revenue_in_usd` decimal(12,10) DEFAULT NULL, 
    `create_space_royalty_in_usd` decimal(12,10) DEFAULT NULL, 
    `create_space_paperbacks_sold` int(11) DEFAULT NULL, 
    `daily_total_revenue` decimal(12,10) DEFAULT NULL, 
    `daily_total_royalty` decimal(12,10) DEFAULT NULL, 
    PRIMARY KEY (`id`) 
) ENGINE=InnoDB AUTO_INCREMENT=301 DEFAULT CHARSET=latin1; 

enter image description here を私は

class AmazonDaily < ActiveRecord::Base 
    self.table_name = "rb_amazon_daily" 
end 

しかし、その後、私は、データベースにsomeDataがを保存しようとしてい

#<AmazonDaily:0x007fffef743a00 
id: nil, 
date: Sat, 16 Jul 2016, 
book_title: "Catalyst Moon: Incursion", 
marketplace: "Amazon.com", 
amazon_kdp_avg_list_price: 0.299e1, 
amazon_kdp_royalty_type: "70%", 
amazon_kdp_revenue_in_usd: 0.598e1, 
amazon_kdp_royalty_in_usd: 0.408e1, 
amazon_kdp_paid_downloads: 2, 
amazon_kdp_free_downloads: 0, 
amazon_ku_pages_read: 0, 
amazon_ku_revenue_in_usd: 0.0, 
create_space_revenue_in_usd: 0.0, 
create_space_royalty_in_usd: 0.0, 
create_space_paperbacks_sold: 0, 
daily_total_revenue: 0.598e1, 
daily_total_royalty: 0.408e1> 

エラーが発生しました: エラー:列012の範囲外の値`

home/jonsdirewolf/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mysql2-0.4.9/lib/mysql2/client.rb:120:in _query': Mysql2::Error: Out of range value for column 'amazon_kdp_revenue_in_usd' at row 1: INSERT INTO rb_amazon_daily ( date , book_title , marketplace , amazon_kdp_avg_list_price , amazon_kdp_royalty_type , amazon_kdp_revenue_in_usd , amazon_kdp_royalty_in_usd , amazon_kdp_paid_downloads , amazon_kdp_free_downloads , amazon_ku_pages_read , amazon_ku_revenue_in_usd , create_space_revenue_in_usd , create_space_royalty_in_usd , create_space_paperbacks_sold , daily_total_revenue , daily_total_royalty`) VALUES ('2016-07-16', 'Catalyst Moon: Incursion', 'Amazon.com', 2.99, '70%', 5.98, 4.08, 2, 0, 0, 0.0, 0.0, 0.0, 0, 5.98, 4.08) (ActiveRecord::StatementInvalid)

` 私は何をしますか?

+0

それがために何かを持ってもらえ「日付」は長さ0ですか? – user7733611

+0

@ user7733611いいえ、確かに - 私は日付の長さを設定しようとしましたが、navicatはテーブルを保存したときにゼロに設定しました – user2950593

答えて

0

事は、SQLテーブルで私の小数の定義にあった、私は例likefo私の小数の列を変更する必要:

`amazon_kdp_revenue_in_usd` decimal(10,5) DEFAULT NULL, 

The declaration syntax for a DECIMAL column is DECIMAL(M,D). The ranges of values for the arguments in MySQL 5.7 are as follows:

M is the maximum number of digits (the precision). It has a range of 1 to 65.

D is the number of digits to the right of the decimal point (the scale). It has a range of 0 to 30 and must be no larger than M.

(これは私を助け:Warning#1264:out of range error in mysql

関連する問題