#1 2020-11-09 14:33:54

Mo0211
Member
Registered: 2018-12-30
Posts: 24

Update Record with related table information

Hi,

i found this shorted example for updating a value on another site:

var
  ExistingMovie: TMovie;

  ExistingMovie := TMovie.CreateAndFillPrepareJoined(DBServer,
      'Title = ?', [], ['District 9']);
    ExistingMovie.Title := 'District 10';
    ServerDB.Update(ExistingMovie);

What is the best way to implement an update for a joined table here?
For Example we have another table which references with a id here and the update should take care of both tables.

I hope my question is clear.
If not, i can post a small part of the code.

Thanks.

Moe

Offline

#2 2020-11-10 08:37:24

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Update Record with related table information

You may just do it in two steps, with direct ORM on the two tables:
1. OneFieldValue() to retrieve the Int64/TID of the joined field
2. UpdateField() to change the 'Title' field
I guess you don't need the full TMovie information.

Or you may just specify the updated field as additional parameter to Update().

Offline

#3 2020-11-11 15:06:00

Mo0211
Member
Registered: 2018-12-30
Posts: 24

Re: Update Record with related table information

Hi ab,

thanks for your quick answer.

i have some more questions here:

when i want to update one TSQL-Record complete with all values, what is the best way to do this?
To I have to name all columns which i want to update?
I tried already to use the Update(tsqlrecord) but this does not seem to work (no error, but no values are changed in db).

In my TSQL-Record, there is another TSQL-Record as a property.
Is it possible to update directly within one update-command also the joined table?
When i want to update now the complete information in both related lines, what would be the best way?

Are there some examples for updating information in an sql-lite database, also for joined tables?

Really thanks for your support here.

Offline

Board footer

Powered by FluxBB