使用 SQL 在 Oracle APEX 中将数字连接在一起
好的。以下是一些背景信息:我创建了一个简单的 APEX 应用程序,它将取代一些静态 HTML 页面、Access 数据库和大量手动工作。用户使用该应用程序向我的团队提交工作请求,提交表格后,信息会以“收据”形式返回给他们,其中包含新的“请求编号”,他们可以使用类似于 UPS 跟踪号码的方式进行查询他们的项目。该数字是提交表的主键,并按序列自动递增。到目前为止,这一切都很完美。
我的问题是,为了让自动递增工作,我的 PK 显然必须是一个“数字”。这又不是一个真正的问题。问题是,在迁移到 APEX 工具之前,我们的“请求#”被格式化为一串 8 位数字长的数字字符串,并在实际数字的左侧包含必要数量的零 (0)。因此,请求#789 实际上在我们的 Access 数据库中存储为 00000789。我的老板表示,当 APEX 工具中显示 # 时,也需要模仿相同的格式,因为这是我们的客户习惯看到的。
我需要请求 # 继续存储为数字,以便我可以继续自动递增,但我需要找到某种方法在显示数字时将适当数量的 0 附加/连接到数字的前面。这可能需要使用 SQL 来完成。我目前正在使用这个简单的 SQL 脚本来显示 #:
SELECT req_num
FROM proj_apex
WHERE req_num = (SELECT MAX(req_num) FROM proj_apex)
Thoughts? APEX 或 SQL 开发人员有什么想法吗?
Ok. Here is some background: I have created a simple APEX application that is going to replace a handful of static HTML pages, an Access Database, and LOTS of manual work. Users use the application to submit work requests to my team and upon submission of the form the information is presented back to them in a 'receipt' with a new 'Request #' which they can use kind of like a UPS tracking number to make inquiries of their project. This number is the primary key of the submitted table and is auto-incremented by a sequence. This all works perfectly so far.
My problem is that for auto-incrementing to work, my PK obviously has to be a 'Number'. Again not really a problem. The issue is that prior to migrating to the APEX tool our 'Request #s' were formatted as a string of numbers 8 digits long with the necessary number of zeros (0's) to the left of the actual number. So Request # 789 is actually stored as 00000789 in our Access database. My boss has indicated that this same format needs to be mimicked when the # is displayed in the APEX tool as well since that is what our clients are used to seeing.
I need the Request # to continue to be stored as a Number so that I can continue to auto-increment but I need to find some way to append/concatenate the appropriate number of 0's to the front of the number when it is displayed. This is will likely need to be done with SQL. I am currently using this simple SQL script to display the #:
SELECT req_num
FROM proj_apex
WHERE req_num = (SELECT MAX(req_num) FROM proj_apex)
Thoughts? Any APEX or SQL developers have ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://www.techonthenet.com/oracle/functions/to_char.php
http://www.techonthenet.com/oracle/functions/to_char.php