I'm re-developing an open-source program developed with MySql and re-writing an method like:
function lastid(){
return mysql_insert_id($conn);
}
How can i perform this function using postgresql instead?
I'm re-developing an open-source program developed with MySql and re-writing an method like:
function lastid(){
return mysql_insert_id($conn);
}
How can i perform this function using postgresql instead?
According to the manual: http://www.postgresql.org/docs/current/static/functions-sequence.html
there is a function lastval()
that
Return the value most recently returned by nextval in the current session. This function is identical to currval, except that instead of taking the sequence name as an argument it fetches the value of the last sequence that nextval was used on in the current session. It is an error to call lastval if nextval has not yet been called in the current session.