[Gambas-user] DataView Help

Christof Thalhofer chrisml at deganius.de
Tue Jul 11 21:11:27 CEST 2023


Am 11.07.23 um 15:56 schrieb Benoit Minisini:

> This is a feature of the underlying database system, so it's up to it to
> make that feature reliable! :-)

Hmm, I disagree. For instance with Postgresql it would only be 
absolutely reliable if this:

 >      DataSource1.Save
 >      i = DataSource1.Connection.Exec(sSQL)[0]

would have been encapsulated inside a transaction.

If 'students_id' is a serial, then the correct procedure would be to:

---

Start a transaction with "Begin;".

Get the next serial number of 'students_id' with

"select nextval(pg_get_serial_sequence('students', 'students_id')) as 
new_id;"

Store the tuple together with students_id = new_id.

Commit the transaction with "Commit;".

If an error happened rollback the transaction with "Rollback;".

---

Other RDBMS may have other commands but act the same.

Alles Gute

Christof Thalhofer

-- 
Dies ist keine Signatur

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230711/9e68785c/attachment.sig>


More information about the User mailing list