You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All,
In the following example I'm getting a type error when trying to specify the decimal precision. Here are the details:
create database bookstore;
set database = bookstore;
CREATE TABLE books (
-> isbn char(14) NOT NULL,
-> title varchar(255) NOT NULL,
-> author varchar(255) NOT NULL,
-> price decimal(5,2) NOT NULL
-> );
CREATE TABLE
INSERT INTO books (isbn, title, author, price) VALUES
-> ('978-1503261969', 'Emma', 'Jayne Austen', 9.44),
-> ('978-1505255607', 'The Time Machine', 'H. G. Wells', 5.99),
-> ('978-1503379640', 'The Prince', 'Niccolò Machiavelli', 6.99);
pq: value type float doesn't match type DECIMAL of column "price"
Our type inference/conversion is still a work in progress. At the moment you'll have to manually insert cast statements (with the realization that you've actually lost precision). Something like:
INSERT INTO books (isbn, title, author, price) VALUES
('978-1503261969', 'Emma', 'Jayne Austen', CAST(9.44 AS DECIMAL));
All,
In the following example I'm getting a type error when trying to specify the decimal precision. Here are the details:
Postgresql reference docs: http://www.postgresql.org/docs/current/static/datatype-numeric.html
The text was updated successfully, but these errors were encountered: