php man page for db2_last_insert_id

Query: db2_last_insert_id

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

DB2_LAST_INSERT_ID(3)							 1						     DB2_LAST_INSERT_ID(3)

db2_last_insert_id - Returns the auto generated ID of the last insert query that successfully executed on this connection

SYNOPSIS
string db2_last_insert_id (resource $resource)
DESCRIPTION
Returns the auto generated ID of the last insert query that successfully executed on this connection. The result of this function is not affected by any of the following: o A single row INSERT statement with a VALUES clause for a table without an identity column. o A multiple row INSERT statement with a VALUES clause. o An INSERT statement with a fullselect. o A ROLLBACK TO SAVEPOINT statement.
PARAMETERS
o $resource - A valid connection resource as returned from db2_connect(3) or db2_pconnect(3). The value of this parameter cannot be a state- ment resource or result set resource.
RETURN VALUES
Returns the auto generated ID of last insert query that successfully executed on this connection.
EXAMPLES
Example #1 A db2_last_insert_id(3) example The following example shows how to return the auto generated ID of last insert query that successfully executed on this connection. <?php $database = "SAMPLE"; $user = "db2inst1"; $password = "ibmdb2"; $conn = db2_connect($database, $user, $password); if($conn) { $createTable = "CREATE TABLE lastInsertID (id integer GENERATED BY DEFAULT AS IDENTITY, name varchar(20))"; $insertTable = "INSERT INTO lastInsertID (name) VALUES ('Temp Name')"; $stmt = @db2_exec($conn, $createTable); /* Checking for single row inserted. */ $stmt = db2_exec($conn, $insertTable); $ret = db2_last_insert_id($conn); if($ret) { echo "Last Insert ID is : " . $ret . " "; } else { echo "No Last insert ID. "; } db2_close($conn); } else { echo "Connection failed."; } ?> The above example will output: Last Insert ID is : 1 PHP Documentation Group DB2_LAST_INSERT_ID(3)
Related Man Pages
maxdb_stmt_execute(3) - php
cubrid_insert_id(3) - php
cubrid_query(3) - php
db2_autocommit(3) - php
db2_rollback(3) - php
Similar Topics in the Unix Linux Community
Insert row without deleting previous data using sed
check if the insert statement is using column names
Insert value to db from text file
Insert query with shell variable with AWK
Variable gets auto updated after function execution