GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
KSQL_LASTID(3) FreeBSD Library Functions Manual KSQL_LASTID(3)

ksql_lastid
get the last insertion row identifier

library “ksql”

#include <sys/types.h>
#include <stdint.h>
#include <ksql.h>

enum ksqlc
ksql_lastid(struct ksql *sql, int64_t *id);

The ksql_lastid function fills in id with the row identifier of the last insertion. If id is NULL, then this does nothing, except that the return value still indicates whether the database is open. If no row was successfully inserted since the database sql was opened, *id is set to 0.

The ksql_lastid function returns KSQL_NOTOPEN if the database is not open or KSQL_OK otherwise.

The following assumes an open database sql. It inserts a row and checks its row identifier. For brevity, it performs no error checking.
int64_t id;
struct ksqlstmt *stmt;

ksql_stmt_alloc(sql, &stmt,
  "INSERT INTO test (foo) VALUES (?)", 0);
ksql_bind_int(stmt, 0, 42);
ksql_stmt_step(stmt);
ksql_lastid(sql, &id);

printf("The last rowid = %" PRId64 "\n", id);

sqlite3_last_insert_rowid(3)
April 20, 2018 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.