Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
KSQL_LASTID(3)		    Library Functions Manual		KSQL_LASTID(3)

NAME
       ksql_lastid -- get the last insertion row identifier

LIBRARY
       library "ksql"

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

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

DESCRIPTION
       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.

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

EXAMPLES
       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);

SEE ALSO
       sqlite3_last_insert_rowid(3)

FreeBSD	Ports 14.quarterly	April 20, 2018			KSQL_LASTID(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=ksql_lastid&sektion=3&manpath=FreeBSD+Ports+14.3.quarterly>

home | help