These two solutions often spill over and arguably break encapsulation of the data-access layer, leaving your code dependent on a specific database driver (and database engine). For example, in PHP (using a PDO interface) a sequence name is often required in order to use the correct sequence:

<?php
// if there was an auto-increment
$conn->exec('INSERT INTO table (data) VALUES(255)');
$id = $conn->lastInsertId();
// but if there was a sequence
$conn->exec('INSERT INTO table (id, data) VALUES(sequence_name.NEXTVAL, 255)');
$id = $conn->lastInsertId('sequence_name');
?>