数字字段项的格式掩码:尾随和“前导”零

发布于 2024-12-09 08:37:50 字数 1313 浏览 1 评论 0原文

我在顶点中显示数字时遇到一些问题,但只有当我通过代码填写它们时。当通过自动行获取来获取数字时,它们就很好了!

前导零

例如,我有一个报告,用户可以单击一个链接,该链接运行 JavaScript 函数。我通过申请流程获得了该记录的详细值。返回值采用 JSON 格式。有几个字段是数字字段。 我的回复如下(fe):

{"AVAILABLE_STOCK": "15818", "WEIGHT": ".001", "VOLUME": ".00009", "BASIC_PRICE": ".06", "COST_PRICE": ".01"}

这里的数字已经“不正确”:小于一的值在.之前没有零。 我有点希望项目上的格式掩码能够捕捉到这一点。如果我指定 FM999G990D000 作为物品重量,我希望它显示 '0.001' 。

但是好吧,我想它只有在通过会话状态时才有效,而不是在通过 $("#").val() 设置项目值时有效?

我哪里出错了?我是在应用程序流程中更改选择的唯一选择吗? 现在:

  SELECT '"AVAILABLE_STOCK": "' || AVAILABLE_STOCK ||'", '||
         '"WEIGHT": "'          || WEIGHT          ||'", '||
         '"VOLUME": "'          || VOLUME          ||'", '||
         '"BASIC_PRICE": "'     || BASIC_PRICE     ||'", '||

我是否需要在此处为​​我的数字字段提供带有格式掩码的 to_char (to_char(available_stock, 'FM999G990D000')) ?

当然,现在我需要将数字放在引号之间,否则当我解析它时会得到无效的 json。

尾随零

我在自动行获取之后的标题点后的页面上有一个应用程序进程。这里计算了几个字段(总计)。使用的变量均指定为 number(10, 2)。所有值均正确并四舍五入为逗号后的 2 个值。我的项目格式掩码也指定为 FM999G999G990D00

然而,当计算值之一在逗号后只有一个有意义的值时,尾随零将被删除。显示为“987.5”,而不是“987.50”。 所以,我有一个数字变量,并像这样分配它: :P12_NDB_TOTAL_INCL := v_totI; 我是否也需要使用格式掩码在这里转换我的数字?

我做错了什么,或者我错过了什么?

I'm having some trouble with displaying numbers in apex, but only when i fill them in through code. When numbers are fetched through an automated row fetch, they're fine!

Leading Zero

For example, i have a report where a user can click a link, which runs a javascript function. There i get detailed values for that record through an application process. The returned values are in JSON. Several fields are number fields.
My response looks as follows (fe):

{"AVAILABLE_STOCK": "15818", "WEIGHT": ".001", "VOLUME": ".00009", "BASIC_PRICE": ".06", "COST_PRICE": ".01"}

Already the numbers here 'not correct': values less than one do not have a zero before the .
I kind of hoped that the format mask on the items would catch this. If i specify FM999G990D000 for the item weight, i'd expect it to show '0.001' .

But okay, i suppose it only works that way when it comes through session state, and not when you set an item value through $("#").val() ?

Where do i go wrong? Is my only option to change my select in the app process?
Now:

  SELECT '"AVAILABLE_STOCK": "' || AVAILABLE_STOCK ||'", '||
         '"WEIGHT": "'          || WEIGHT          ||'", '||
         '"VOLUME": "'          || VOLUME          ||'", '||
         '"BASIC_PRICE": "'     || BASIC_PRICE     ||'", '||

Do i need to provide my numberfields a to_char with the format mask here (to_char(available_stock, 'FM999G990D000')) ?

Right now i need to put my numbers between quotes ofcourse, or i get invalid json when i parse it.

Trailing Zero

I have an application process on a page on the after header point, right after an automated row fetch. Several fields are calculated here (totals). The variables used are all specified as number(10, 2). All values are correct and rounded to 2 values after the comma. My format masks on the items are also specified as FM999G999G990D00.

However, when one of the calculated values has only one meaningfull value after the comma, the trailing zeros get dropped. Instead of '987.50', it is displayed as '987.5'.
So, i have a number variable, and assign it like this: :P12_NDB_TOTAL_INCL := v_totI;
Would i need to convert my numbers here too, with format mask?

What am i doing wrong, or what am i missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤独陪着我 2024-12-16 08:37:50

如果您不对其进行数学计算并且更关心格式,我建议尽可能将其视为 varchar/string 而不是数字。

If you aren't doing math on it and are more concerned with formatting, I suggest treating it as a varchar/string instead of as a number wherever you can.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文