Skip to content
Discussion options

You must be logged in to vote

Hi !

Most databases have a builtin function that does what you want. In sqlite it's last_insert_rowid. SQLPage runs all statements from a file on the same connection, sequentially, so it's safe to use even under high concurrency.

drop table if exists shelves;
create table shelves
  (id integer primary key autoincrement, 
    name, description, owner_id);

INSERT INTO shelves
  (name, description, owner_id)
VALUES
  (:name, :description, :session_user);

SET new_id = last_insert_rowid();

select 'debug' as component, $new_id as new_id;

That said, I don't like the error message you are seeing, I'll look into it !

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@keisisqrl
Comment options

Answer selected by keisisqrl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants