Get the next row defined by an offset in oracle PL/SQL
<p>I have a function which takes an integer parameter. I need to return the row which is the next, second,
previous from the current row. E.g. 1 means the next row, -1 the previous row, 2 the
second row from the current etc. </p>

<p>In other words the function must first store a value into a variable, which represents the next, previous or same row. This is to be defined by an offset parameter which the function expects. The code below only adds or subtracts the offset value to current row value. </p>

<p>The function also uses a global variable from the package interface, in order to pinpoint the row which needs to be offset-ed. </p>

<pre><code>    function my_function (v_offset integer) 
    return number 
    is

    var flight.flightID%TYPE;

    BEGIN
    if v_offset&gt;0 then
     select something
     INTO var
     from somewhere
     where id = v_global + v_offset; 
    else 
     select something
     INTO var
     from somewhere
     where id = v_global-givennr; 
     end if;
    RETURN var;

  end my_function;
  /
</code></pre>

<p>This is my code so far.</p>