英文:
How to concatetante sysdate to result output in oracle query
问题
我对Oracle不太了解,作为项目的一部分,我尝试在我的SQL插入列中的序列ID生成器中添加或连接日期值。
生成序列号的查询是:
select nvl(max(RII_INDENT_ID_SL), 0) + 1 as ID from T_RAKE_INDENT_IBMD
该查询以整数形式输出,例如23、24等,作为序列号,它取最大值然后加1,从而创建新的序列号。
为了使它成为唯一的ID,我想要将sysdate的值,特别是年份和月份,添加到结果输出中。
所以结果会是这样的:
1-23/09/2022
通过连接操作符||
可以实现吗?
英文:
I am new to oracle and as part of a project I was trying add or concatenate date value to serial id
generator in my sql insert column .
The query generating serial numbers is
select nvl(max(RII_INDENT_ID_SL),0 +1 ID from T_RAKE_INDENT_IBMD)
This query gives output in the form of integers like 23,24 etc as serial numbers taking the maximum value and adding 1 thus creating new serial no.
In order to make it a unique ID I want to add sysdate value particularly the year and month to the result output.
so the result will be something like this:
1-23/09/2022
Can it be done by concatenating || the sysdate value?
答案1
得分: 0
可以使用||运算符来完成:
select nvl(max(RII_INDENT_ID_SL), 0) + 1 || TO_CHAR(SYSDATE, 'DD/MM/YYYY') as ID
from T_RAKE_INDENT_IBMD
英文:
Absolutely it could be done using || operator -
select nvl(max(RII_INDENT_ID_SL),0 +1 || TO_CHAR(SYSDATE, 'DD/MM/YYYY') ID
from T_RAKE_INDENT_IBMD)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论