C program to get the last row id of a database table in SQLite
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
In this program, we will insert records into the employee table using source code and then print the last row id on the console screen.
Program/Source Code:
The source code to get the last row id of a database table in SQLite is given below. The given program is compiled and executed successfully on Ubuntu 20.04.
Output:
In the above program, we included the sqlite3.h header file to uses SQLite related functions. Here, we inserted two records into the employee table in the "MyDb.db" database using sqlite3_exec() by passing a specified SQL statement. Here, we used the sqlite3_last_insert_rowid() function to get the last row id and print row id on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer