onApplyRecord problem

Angelo

Member
I am using an oracle dataset with a grid containing a check box column.
the recordset is not updatable, because is a complex union of joined dataset.

sql for oracleDataSet:

select '0' as NumRow,
lab_tipoprova.idtipoprova,
lab_tiposprova.idtiposprova,
0 as idDenpart,
0 as checkFld,
null as flgtest,
lab_tipoprova.destipoprova,
lab_tiposprova.destiposprova

from lab_tipoprova,
lab_tiposprova
where lab_tipoprova.idtipoprova = lab_tiposprova.idtipoprova (+)
and lab_Tiposprova.Idtiposprova not in (select lab_tiprvdenpart.idtiposprova from lab_tiprvdenpart
where lab_tiprvdenpart.iddenpart = :iddenpart and
(lab_tiprvdenpart.idtipoprova = lab_tipoprova.idtipoprova
or lab_tiprvdenpart.idtiposprova = ''))

union

select ROWIDTOCHAR(lab_TiprvDenPart.rowid) as numRow,
lab_tiprvdenpart.idtipoprova,
lab_tiprvdenpart.idtiposprova,
Lab_tiprvdenpart.iddenpart,
1 as checkFld,
lab_tiprvdenpart.flgtest,
Lab_tipoprova.Destipoprova,
lab_tiposprova.destiposprova
from lab_tiprvdenpart, lab_tipoprova, lab_tiposprova
where lab_tiprvdenpart.iddenpart = :iddenpart
and lab_tiprvdenpart.idtipoprova = lab_tipoprova.idtipoprova
and lab_tiprvdenpart.idtiposprova = lab_tiposprova.idtiposprova (+)

when i check the box, I want to insert a new row in the table lab_tiprvdenpart, and when
uncheck, i want delete the row.

there are cases in wich i need also update the table

Questions are:
May somebody show me the code to do inset and delete in onApplyRecord event.

Why in the same event if I set NewRowId with the value that I got from Query, I get an error no rowid.

Code I'm using for testing onApplyRecord:

procedure TDMDenPartic.odsProveApplyRecord(Sender: TOracleDataSet;
Action: Char; var Applied: Boolean; var NewRowId: String);
begin
if Action = 'U' then
begin
showMessage(odsProveDESTIPOPROVA.AsString + ' ' + odsProveDESTIPOSPROVA.AsString);
if odsProveCHECKFLD.Value = 0 then
showMessage('Cancella prova')
else
if odsProveNUMROW.Value = '0' then
showMessage('Inserisce prova')
else
NewRowId := odsProveNUMROW.Value;
Applied := True;
end
else
NewRowId := odsProveNUMROW.Value;
end;

Thanks. Angelo
 
Perhaps you can use the PkgApply demo for a complete example?

------------------
Marco Kalter
Allround Automations
 
Back
Top