Topic: SQL INSERT

Hi everyone,

First of all, I like this product.

I'm new to this product and been playing with it for the past couple days as time permit. Now, I've trying to run a simple query where when I click to save new record is not inserting the data to all tables. Is only doing the first insert and not the rest

INSERT INTO "Inventory" ("ItemName","ItemDesc")
    VALUES ('{txtItemName}','{txtItemDesc}');
INSERT INTO "InvDetails" ("ItenLocation","QtyStock","DateAdded")
    VALUES (last_insert_rowid(),'{txtItemLoc}','{txtQtyStock}','{dtAdded}');
INSERT INTO "InvPictures" ("ItemPic")
    VALUES (last_insert_rowid(),'{picItenUp}');



Any advise will be very much appreciated.

Re: SQL INSERT

i_rortiz,
Welcome to MVD.


Generally speaking each form with a save action will only save one record in one table. MVD does this automatically. You do not need to put in your own SQL inserts. In your scenario, your inventory form will save the inventory record and your inventory details form will save your inventory details record. Having said this, using MVD scripts you can do other SQL updates to other tables if your project requires it. But in a typical master-detail scenario it is not a requirement.


Hope this helps. If you have more questions, do not hesitate to ask. There are plenty of people on this forum who can help.

Re: SQL INSERT

I guess you are talking about the "VALUES (last_insert_rowid()" which is valid with a SELECT according to SQLite documentation. You may have to modify your INSERT to add a "(SELECT (last_insert_rowid())" or you would have to re-think your insert into as a wole package...