Search code examples
sqloracleplsqloracle11g

How to concatetante sysdate to result output in oracle query


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?


Solution

  • 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)