Pgsql报错: invalid input syntax for integer:‘ ‘

这篇具有很好参考价值的文章主要介绍了Pgsql报错: invalid input syntax for integer:‘ ‘。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

业务sql偶尔会报错,意思是给integer了空字符串

invalid input syntax for integer:' '

起初我以为是alarm.status in () 这里传参问题,
因为我试了几次 把1换成2就不会报出这个错误,但看了很久也没发现1为什么会被认为是空字符

后来才发现,是因为类型强转的问题,应该是status为1时,camera.device_id为空了,导致强转为integer失败,因此报错;

修改前:

 select alarm.*,camera.status as camera_status, region.name
 from ai.alarm_log alarm 
 left join ai.camera on alarm.camera_id = camera.id 
 left join vcenter.device d on d.id = camera.device_id::INTEGER left join ai.region on region.id = d.org_id::BIGINT 
 WHERE alarm.start_time BETWEEN to_timestamp(1692806400) AND to_timestamp(1693497599) 
 AND alarm.status in (0,1)

所以我对强转的字段加了空值转换,就不会再出现这个问题了
修改后:文章来源地址https://www.toymoban.com/news/detail-803129.html

 select alarm.*, camera.status as camera_status, region.name 
 from ai.alarm_log alarm 
 left join ai.camera on alarm.camera_id = camera.id 
 left join vcenter.device d on d.id = COALESCE(NULLIF(camera.device_id,''),'0')::INTEGER  
 left join ai.region on region.id = COALESCE(NULLIF(d.org_id,''),'0')::BIGINT 
 WHERE alarm.start_time BETWEEN to_timestamp(1692806400) AND to_timestamp(1693497599) AND alarm.status in (0,1)

到了这里,关于Pgsql报错: invalid input syntax for integer:‘ ‘的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • INVALID_ARGUMENT : Invalid rank for input: modelInput Got: 3 Expected: 4 Please fix either the input

    HXDM 看看是不是报的这个错 modelInput 是我 onnx 模型输入的名字 这个错,意思很简单,意思是 onnx 模型的输入是 结果你送入了 一个维度是4,一个维度是3,所以是INVALID ARGUMENT(无效的输入) 我记录这个错,主要是 Invalid rank for input ,他要是说是 Invalid shape for input ,我就秒懂,但

    2024年02月13日
    浏览(37)
  • 【Python】pip install 报错File “<stdin>“, line 1, pip install ultralytics SyntaxError: invalid syntax

    python安装 ultralytics 包的时候发现了这个问题。 刚开始在命令提示符中输入pip install ultralytics,显示File “<stdin>“, line 1, pip install ultralytics SyntaxError: invalid syntax 后面又以管理员的身份运行 也是一样的问题,查阅资料后发现 在cmd中使用pip命令安装python库时,如果先输入pyth

    2024年02月03日
    浏览(34)
  • RuntimeError: shape ‘[-1, 784]‘ is invalid for input of size 68076

    在应用torch进行测试时,有可能出现这种错误: RuntimeError: shape \\\'[-1, 784]\\\' is invalid for input of size 68076 这个错误通常是由于输入数据的大小与模型期望的输入大小不匹配导致的。具体地说,在这个错误信息中, [-1, 784] 表示输入张量的形状是一个二维张量,第一个维度大小是 -1,

    2024年02月12日
    浏览(27)
  • packet tracer报错Invalid input detected at ‘^‘ marker.

    计算机网络实验2. 交换机MAC地址表建立与帧转发 本实验需要添加静态mac地址表项,老师的视频里是 输入enable,进入特权模式 输入config terminal 进入全局配置模式 输入mac-address-table static 【ip地址】 vlan 1 interface 【写错误端口】,分析错误端口的时候,转发数据和接受数据的情

    2024年02月12日
    浏览(24)
  • org.postgresql.util.PSQLException: Bad value for type long

    项目用 springboot+mybatis +mybatisplus, 数据库是:postgresql  。 执行查询时候返回错误。 org.springframework.dao.DataIntegrityViolationException: Error attempting to get column \\\'city_id\\\' from result set.  Cause: org.postgresql.util.PSQLException: Bad value for type long :  ; Bad value for type long : ; nested exception is org.postgres

    2024年02月07日
    浏览(29)
  • 【异常】PGSQL提示 ERROR: operator does not exist: character varying = integer

    这是数据库和实体类里面字段类型不一致造成的报错#

    2024年02月03日
    浏览(30)
  • 【npm报错】解决invalid json response body at https://registry.npmjs.org

    报错信息: npm ERR! code FETCH_ERROR npm ERR! errno FETCH_ERROR npm ERR! invalid json response body at https://registry.npmjs.org/ @riophae%2fvue-treeselect r eason: Invalid response body while trying to fetch https://registry.npmjs.org /@riophae%2fvue-treeselect: 报错原因 是node和npm的版本太高了,我当时安装的是最新版本,最新版

    2024年02月02日
    浏览(31)
  • 【报错解决】org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

     对于这种错误,一般在于mapper接口与xml文件无法绑定。 解决方案: 1.检查xml文件名是否与mapper接口名一致。 2.检查xml文件中namespace是否与mapper接口的全类名一致。(按住ctrl点击能跳转就没问题) 3.是否在主启动类上标注了@MapperScan(“mapper接口所在包的全包名”)或在map

    2024年02月15日
    浏览(55)
  • 关于FFmpeg报错Error when loading first segment和Invalid data found when processing input

            如果在下载ts文件时已经解密过,FFmpeg在使用m3u8文件合并时就不要带#EXT-X-KEY。         一开始我查看了很多关于这两个报错的博客,如下 使用ffmpeg将m3u8文件转为mp4 m3u8及TS文件下载解密:用FFmpeg解密合并m3u8中ts文件(二) ffmpeg合并m3u8 ts key文件 解决Invalid da

    2023年04月09日
    浏览(29)
  • [初学Spring Boot](2):单元测试报错:org.junit.runners.model.InvalidTestClassError:Invalid test class

    是建项目时自动生成的测试类,结果还是报错了。大无语事件。 就是IDEA自建测试时导错包了。  注释掉的时原来自导的,换成短的就好了。 经查证,长的是升级版,junit5,spring boot版本在2.2之后,方法不要public修饰; 短的,是旧版,junit4,spring boot版本在2.2之前,方法要用

    2024年02月07日
    浏览(35)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包