Operation (selector)
De Wiki1000
property Operation:string;
Lecture/Ecriture
Cette propriété définit le nom d'une opération SQL de mise à jour.
Lorsque les propriétés Operation et OperationId sont définies, l'opération CopyTo alimente une classe SQL des objets insérés.
Cette table peut ensuite être jointe dans des opérations SQL successives.
Exemple
Use of TsqlOperation to chain SQL operations
Type // We want to create a TPiece from a TBordereauReglement vueBordereau = viewOf(TBordereauReglement) .... define TPiece columns .... end; // Then we want to add one ecriture by reglement of the borderau to this piece // vueReglement = viewOf(TReglement) vl:TsqlOperation = join('(opeId=%ArgOpeId) and (operation=%ArgOperation)'); oidBordereau:TOID = oidBordereauReglement; oidpiece:TOID = vl.oidTargetObject; // OID of the piece which has been created .... define TEcriture columns .... end; // And finally we want to update the TReglement with the oid of the TEcriture created for this reglement. // vueUpdateReglement = viewOf(TReglement) vl:TsqlOperation = join('(opeId=%ArgOpeId) and (operation=%ArgOperation) and (oidSourceObject=self.oid)'); oidEcriture:TOID = oidEcriture; oidTargetEcriture:TOID = vl.oidTargetObject; // OID of the TEcriture for this TReglement oidBordereau:TOID = oidBordereauReglement; end; // foo(oidBordereauReglement) var opeId:string; begin opeId := CreateGuid; try withP long transaction do begin // Create a TPiece from this TBordereauReglement // sel := vueBordereau.CreateSelector('(oid=%1)','',True,[oidBordereauReglement]); sel.OpeId := opeId; sel.Operation := 'Piece'; sel.CopyTo('TPiece',[],[]); // We could also retrieve the OID of the TPiece from the selector result // because the operation has created only one object // aOidPiece := sel.lastOpeFirstOID; // Create TEcriture (s) from TReglement (s) of the TBordereauReglement // sel := vueReglement.CreateSelector('(oidBordereau=%1)','',True,[oidBordereauReglement]); // To retreive the TPiece OID sel.AddParameter('ArgOpeId',opeId); sel.AddParameter('ArgOperation','Piece'); // To insert in the TsqlOperation the TEcriture we create sel.OpeId := opeId; sel.Operation := 'EcrReg'; sel.CopyTo('TEcriture',[],[]); // Update the TReglement from the TEcriture which has been created for this Reglement // sel := vueUpdateReglement.CreateSelector('(oidBordereau=%1)','',True,[oidBordereauReglement]); // To match TReglement with TEcriture sel.AddParameter('ArgOpeId',iOpeId); sel.AddParameter('ArgOperation','EcrReg'); sel.Update(['oidEcriture'],['oidTargetEcriture']); end; finally // Clean up the TsqlOperation TsqlOperation.CleanOpe(aOpeId); end; end;
Voir aussi :
| Whos here now: Members 0 Guests 0 Bots & Crawlers 1 |