How to get current value of given variable [by using "sequence_get_all()"]?


I can set vars by using sequence_set and get values using sequence_next but can’t obtain current value by using sequence_get_all() / get_keyword ()
[unless by using loop and “cast” function for search].

Here’s the example:

declare sequence_name varchar;         
sequence_name := 'sequence_test7';
sequence_set (sequence_name, 125, 0 );
s_keys  := sequence_get_all();
http(concat(sequence_name,': " ', get_keyword (sequence_name, s_keys, 'no data', 1),' "<br/>'));
foreach (any k in s_keys) do { 
if(cast (k as varchar) = sequence_name){
        http(concat('Wow, we can get the value using "cast" for key: ', k, ' : ', get_keyword (k, s_keys, null), '<br/>')); 
if(i='key'){i := 'value';}else{i := 'key';}  
http(concat(sequence_name, ' obtained thru "sequence_next": ', sequence_next (sequence_name), '<br/>')); 
http(concat(sequence_name, ' obtained thru "sequence_next": ', sequence_next (sequence_name), '<br/>'));


sequence_test7: " no data "
Wow, we can get the value using "cast" for key: sequence_test7 : 125
sequence_test7 obtained thru "sequence_next": 125
sequence_test7 obtained thru "sequence_next": 126


1 What’s the right way to get current value of given variable ?
2 By the way, why “sequence_next” returns current value then called first time ? It’s looks wrong.


You can use 'sequence_set (sequence_name,0, 2)` to get the value of sequence. If sequence is incremented then value is the next increment.


1 Like