lastuid - Returns last uid of an auto_increment field.
lastuid(( [db:pointer] );
This function is used to return the last UID, that is the user identifier last used in an auto_increment field.
In a database such as MYSQL, you can add information. When a next element is added, and if it’s an auto_increment, this information will be indexed. This is the UID.
The user might need this function to find the number (UID) characterizing the last piece of information added to the database
Note: In the followings examples, the _ between the { should be removed to make it work.
res={_{ a=sql("drop table IF EXISTS ? ;","sn_test1"); a=sql("create table sn_test1 (uid INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, firstname varchar(255), lastname varchar(255), sn_cdate datetime, sn_mdate datetime, sn_cuid int, sn_muid int);"); for(i=1;i<=5;++i) do a=sql("insert into sn_test1 set firstname = '?', lastname='?';", "f" .+ i,"l" .+ i ); lastuid(); endfor i=insert(table:"sn_test1",fields:{firstname:"pierre",lastname:"laplante"}); i.uid; lastuid(); . return res=1234566.
Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
1.0 2014-09-09 21:24:14 laplante@sednove.com