Question: I want to get the value of the last ID insert in a table. How I can do this?

Answer: 
```
SELECT IDENTITY_VAL_LOCAL() AS VAL FROM SYSIBM.SYSDUMMY1

```

See [docs](http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0004231.html).
Have a look at this answer.

<http://www.sitepoint.com/php-database-db2/>

```
// get the last inserted ID into the specified table  
// int lastInsertID(string $tblName)  
function lastInsertID($tblName)  
{  
 if ($this->transIsOpen())  
 {  
   $sql = "SELECT SYSIBM.IDENTITY_VAL_LOCAL() AS id FROM " . $tblName;  
   $rs = $this->query($sql);  
   return $this->fetch($rs, "id");  
 }  
 return -1;  
}

```

OR this

<http://www.php.net/manual/en/function.db2-last-insert-id.php#98361>