[Err] ERROR: invalid input syntax for integer: "1.0"

简介: [Err] ERROR: invalid input syntax for integer: "1.0"

一、问题描述


      在执行查询操作时,报了这个错误,通过分析,不是sql语句语法错误,如果是sql语法错误,就会报哪一行有问题,这个一看就是查询PostgreSQL数据类型搞错了,一个不是bigint类型的数据,数据库中保存的值为 1.0 .查询的时候让其作为bigint类型导致的。sql示例:

select  (
        ext ->> 'weekly_outpatient_days'
    ) :: BIGINT AS weekly_outpatient_days from test

二、解决方案

拿到问题sql,查看哪些字段被定为bigint类型了,然后改成其他类型的,我改为numeric类型就顺利解决了。

select  (
        ext ->> 'weekly_outpatient_days'
    ) :: numeric AS weekly_outpatient_days from test

三、总结

     出现这种问题的原因还是对PostgreSQL数据类型不了解。

1、数字类型如下

image.png

2、字符串类型如下:

image.png

3、一般整数类型用Integer或者bigint,高精度类型用 numeric,字符串类型用text,具体的细化请查询表格。

目录
相关文章
|
6月前
|
Unix Linux Shell
syntax error: unexpected end of file
syntax error: unexpected end of file
33 0
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
error C2449: found ‘{‘ at file scope (missing function header?)和error C2059: syntax error : ‘}‘
122 0
|
6月前
|
Perl
报错:error Parsing error: x-invalid-end-tag
报错:error Parsing error: x-invalid-end-tag
136 0
|
6月前
Excel上传出错:TypeError [ERR_INVALID_ARG_TYPE]: The “path“ argument must be of type string or an instan
Excel上传出错:TypeError [ERR_INVALID_ARG_TYPE]: The “path“ argument must be of type string or an instan
|
人工智能 自然语言处理 语音技术
Invalid prop: type check failed for prop “index“. Expected String with value “5“问题解决
Invalid prop: type check failed for prop “index“. Expected String with value “5“问题解决
120 0
Uniapp Syntax Error: Error: Unbalanced delimiter found in string
Uniapp Syntax Error: Error: Unbalanced delimiter found in string
249 0
error C2041: illegal digit ‘9‘ for base ‘8‘ | error C2059: syntax error: ‘bad suffix on number‘
error C2041: illegal digit ‘9‘ for base ‘8‘ | error C2059: syntax error: ‘bad suffix on number‘
140 0
|
关系型数据库 MySQL C++
Error:error C2601: ‘b‘ : local function definitions are illegal error C2063: ‘b‘ : not a function
Error:error C2601: ‘b‘ : local function definitions are illegal error C2063: ‘b‘ : not a function
179 0
|
关系型数据库 MySQL C++
Error:fatal error C1010: unexpected end of file while looking for precompiled head
Error:fatal error C1010: unexpected end of file while looking for precompiled head
116 0