<p>Is there some way to get a value from the last inserted row?</p>

<p>I am inserting a row where the PK will automatically increase, and I would like to get this PK. Only the PK is guaranteed to be unique in the table.</p>

<p>I am using Java with a JDBC and PostgreSQL.</p>

The sequences in postgresql are transaction safe. So you can use the
```
```
currval(sequence)
```
```
Quote:
currval
Return the value most recently obtained by nextval for this sequence
    in the current session. (An error is
    reported if nextval has never been
    called for this sequence in this
    session.) Notice that because this is
    returning a session-local value, it
    gives a predictable answer even if
    other sessions are executing nextval
    meanwhile.