title: How to create a function in DB2 that returns the value of a sequence?
body: <p>How to create a function in DB2 that obtains a value from a sequence and returns it? </p>
  
  <p>It should be possible to use that function in select or insert statement, e.g:</p>
  
  <pre><code>select my_func() from xxx
  insert into xxx values(my_func())
  </code></pre>
  
  <p>Basically I am using the sequence value in a complex formula, and I'd like to encapsulate the calculation inside a function.</p>
  
  <p>Edit: I am not asking how to simply get next value from sequence.</p>