on 12-13-2018 6:38 AM
How to create a sequence in the below format in hana
String_Current date_Sequence number?
In case the sequence number part must not be a running number per String/Current Date combination you can simply create a scalar function which creates that format for you.
Example:
FUNCTION "MISC"."test.misc.functions::ownSequence" ( iv_string nvarchar(100) )
RETURNS ev_result nvarchar(256)
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER AS
BEGIN
select :iv_string || '_' || to_nvarchar(current_date, 'YYYYMMDD') || '_' || "test.misc.sequences::test".nextval
into ev_result
from dummy;
END;
The scalar function uses a simple sequence to get a sequence number and concatenates it with a passed string information and the current date (in this case coverted to format YYYYMMDD).
Executing the scalar function like this ...
select "test.misc.functions::ownSequence"( 'testString') from dummy;
... produces a result like this:
testString_20181213_21
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, then you have to define a synonym for SYS.DUMMY in addition. You can check the section "Simple Example" in blog post https://blogs.sap.com/2017/01/06/synonyms-in-hana-xs-advanced-introduction/ for that.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.