Tell HN: SQLite3 does have something like stored procedures
Hi! I&#x27;m from the other comment chain you originally posted this on. One question - how should I keep track of generated primary key IDs for future inserts? The best I could come up with is:<p><pre><code>  CREATE TRIGGER role_user_view_trigger
  INSTEAD OF INSERT ON role_user_view
  FOR EACH ROW
  BEGIN
  INSERT INTO role(name) VALUES(new.role_name);
  INSERT INTO user(name) VALUES(new.user_name);
  INSERT INTO role_user(role_id, user_id, created_at) VALUES(
    (SELECT id FROM role WHERE name = new.role_name),
    (SELECT id FROM user WHERE name = new.user_name),
    &quot;now&quot;
  );
  END;
</code></pre>
Full code at <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;bbkane&#x2F;ed385787f06efe4473f3cb7a3b32c8ac" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;bbkane&#x2F;ed385787f06efe4473f3cb7a3b32c...</a><p>Do you know of a better way than those select statements (which I presume are slow) to get the IDs?