title: Options to retrieve the current (on a moment of running query) sequence value
body: <p>How is it possible to get the current sequence value in postgresql 8.4?</p>
  
  <p>Note: I need the value for the some sort of statistics, just retrieve and store. Nothing related to the concurrency and race conditions in case of manually incrementing it isn't relevant to the question.</p>
  
  <p>Note 2: The sequence is shared across several tables</p>
  
  <p>Note 3: <code>currval</code> won't work because of:</p>
  
  <ul>
  <li>Return the value most recently obtained by nextval for this sequence in the current session</li>
  <li><code>ERROR: currval of sequence "&lt;sequence name&gt;" is not yet defined in this session</code></li>
  </ul>
  
  <p>My current idea: is to parse DDL, which is weird</p>