I’d like a basic understanding of how to properly use UpdateSQL with params. I’ve had no problems using SQL with params, but UpdateSQL with params is driving me around the bend.
Table “Players”:
Id, integer; primary index
Nm: 25-char string
Rtg: Integer
tSQLQuery sqlPlayers:
SQL is: Select * From players
updateSQL is: (the params have been defined):
UPDATE players SET Nm = :Nm
WHERE Id = :OLD_Id
tDatasource dsPlayers: its dataset is the above query
Form: tdbText field for Id; and tdbEdit fields for Nm and Rtg. There’s also a navbar and a grid. Their datasource is all dsPlayers
Here are my questions:
- Can the updateSQL be triggered implicitly? sqlPlayers.update mode is set to upWhereChanged, but this hasn’t worked for me.
- How about explicitly, for example with code in the navbar’s nbPost event? I have tried this, and the posted changes don’t seem to stick.
- Are there recommended triggers, such as sqlPlayers.beforePost or sqlPlayers.afterPost? (I’ve tried various permutations, and I’d get stack overflows).
- Do I have to explicitly close the query and then re-open it?
- Does this require a tSQLTransaction object, with params defined in the tSQLQuery's Transaction.Params list?
Many thanks in advance to anyone who can clear this up.