As a further response, regarding that Martina said "insert ... new row and get back the id of this last inserted row", I believe that this likely reflects a poor design. Wherever possible, every field of a row to insert including its identifiers should be known BEFORE inserting the row, and that way, you don't need to ask afterwards what the id is, you already know because it is the value you told it to use when doing the insert. -- Darren Duncan

On 2016-06-27 11:58 PM, Hick Gunter wrote:
Do not use SQLite for concurrent access over a network connection. Locking 
semantics are broken for most network filesystems, so you will have corruption 
issues that are no fault of SQLite. If your application requires concurrent 
network access, you should be using either a network client/server DBMS or 
programming your own Client/Server pair with the server process calling the 
SQLite API to modify the db file held on the servers' local filesystem.

SQLite uses file level locking as documented on the SQLite main page.

A cursor (CURrent Set Of Records) is a concept designed for reading data, not writing. SQLite does not 
support navigation other than retrieving the result set in the order specified in the select statement. No 
"paging" backwards. It is possible to simulate a cursor, but the "simple" solutions may 
be imperformant for large result sets (e.g. producing half the result set to display a small number of 
records on a "middle page").

I assume you are looking for "transactions". SQLite supports both explicit transactions 
(BEGIN ... COMMIT/ROLLBACK) and "automatic" Transactions (each statement is ist own 
transaction). If you are just inserting/modfying a set of rows (this also includes a single row) 
within a single table, automatic transactions are sufficient. If you require multiple changes to 
multiple rows in one or more tables to complete together or not at all, then you need an explicit 
transaction.

Gunter

-----Ursprüngliche Nachricht-----
Von: sqlite-users-boun...@mailinglists.sqlite.org 
[mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Martina 
Pasini
Gesendet: Montag, 27. Juni 2016 20:51
An: sqlite-users@mailinglists.sqlite.org
Betreff: [sqlite] How to use "cursors" in c#

Hello to Everyone!

I am sorry to bother you, but I am new to DB and SQLite and I have a doubt.

I am programming in c# and I have to insert into a .sqlite file a new row and get back 
the id of this last inserted row. This file "unfortunately"
might be located on an internal network and other users might try to add other 
rows in the meantime.

I have not studied yet how to manage locking etc (will I need it only when 
editing a row or also when adding a new one?)

For this case, when I add a new row, could it be sufficient to use a cursor or 
something similar? Could you give me some advice/links I should read to 
understand how to manage this process?

Thank you very much for you kind attention!

Best Regards,

Martina

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to