[Gambas-user] DataView Help

Gianluigi gradobag at gradobag.it
Tue Jul 11 22:35:57 CEST 2023


Il 11/07/23 21:11, Christof Thalhofer ha scritto:
> 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
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----

Hi Christof,

you should talk about 'LastInsertId' and the current project is a small 
test on SQLite not on a data-server.

Regards

Gianluigi



More information about the User mailing list