博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Oracle将数值转化成负数的写法
阅读量:2499 次
发布时间:2019-05-11

本文共 832 字,大约阅读时间需要 2 分钟。

最近使用PL SQL在写报表存储过程的时候,需求人员提出要将提现金额写成负值的形式
最初的写法如下:
--计算提现金额
update elmp_daily_fund
   set WITHDRAW_AMOUNT =
       (select
to_number('-' || (sum(l.amount) / 100))
          from mis.ELMP_REPORT_CHARCASHFILL@db_mis l
         where l.countdate >= begin_date
           and l.countdate < begin_date + 1
           and l.reporttype = 1
           and status = 0)
 where REPORT_DATE = begin_date;
报表JOB运行了几天,出现报错,ORA-01722 invalid number
查询了一下论坛,发现有朋友问同样的问题
解决方法是直接使用 - 和 abs 函数,更改后的SQL如下:
--计算提现金额
update elmp_daily_fund
   set WITHDRAW_AMOUNT =
       (select
-abs(sum(l.amount) / 100)
          from mis.ELMP_REPORT_CHARCASHFILL@db_mis l
         where l.countdate >= begin_date
           and l.countdate < begin_date + 1
           and l.reporttype = 1
           and status = 0)
 where REPORT_DATE = begin_date;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26506993/viewspace-2059684/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26506993/viewspace-2059684/

你可能感兴趣的文章
jQuery 基础
查看>>
USE平台构件属性无法显示的一种解决办法
查看>>
齐次坐标
查看>>
[SQLite]使用记录
查看>>
HttpRequest 类
查看>>
Qt使用信号与槽时出现的错误“Incompatible sender/receiver arguments”
查看>>
MYSQL:基础——触发器
查看>>
JavaScript:学习笔记(9)——Promise对象
查看>>
内存泄露检测 vld
查看>>
优秀HTML5网站学习范例:从“饥饿游戏浏览器”谈用户体验
查看>>
spring security原理
查看>>
js 验证各种格式类型的正则表达式
查看>>
POJ2392
查看>>
Form表单的主要Content-Type
查看>>
02ython基础知识(一)
查看>>
739. Daily Temperatures - LeetCode
查看>>
filter与interceptor的区别
查看>>
Linux从入门到精通——linux系统中的磁盘管理
查看>>
Shell脚本中的二维字符串列表
查看>>
ajax---实例
查看>>