0

Im trying to create a CRUD form using a TcxGrid. My Components: TcxGrid -> TDataSource -> TClientDataSet -> TDataSetProvider -> TSQLQuery

Query is select * from tt_BraUCFormatoSUI, Provider has UpdateMode=upWhereAll, ClientDataset has 2 fields: ID_UC and ID_SUI.

Running the .exe and trying to create, edit or delete any row, the row changes in the form if edit, or disappear if delete but this change is not evident in database.

In debug mode When executing ApplyUpdates(0) in the AfterDelete event (when I click on the minus button of the navigator), it shows:

First chance exception at $75B1B512. Exception class TDBXError with message 'ORA-01722: invalid number'. Process Project3.exe (12052)

First chance exception at $75B1B512. Exception class EDatabaseError with message 'Unable to find record. No key specified'. Process Project3.exe (12052)

This is how my form looks like:

enter image description here

And this is the code, it's quite simple, but I don't know if I have been missing something

procedure TForm3.cdBraUCFormatoSUIAfterDelete(DataSet: TDataSet);
begin
 cdBraUCFormatoSUI.ApplyUpdates(0);
 end;

procedure TForm3.cdBraUCFormatoSUIAfterPost(DataSet: TDataSet);
begin
 cdBraUCFormatoSUI.ApplyUpdates(0);
end;

procedure TForm3.FormCreate(Sender: TObject);
begin
 cdBraUCFormatoSUI.Open;
end;

ADITIONAL INFO: This table only has one restriction, ID_UC and ID_SUI can't have duplicates i.e (ID_UC:1 and ID_SUI: 2 twice is not able)

BaldwinIV
  • 147
  • 10
  • What is the return value of `cdBraUCFormatoSUI.ApplyUpdates(0)`? – MartynA Sep 09 '21 at 20:43
  • Makes no sense to use the extra complexity of client datasets/providers and to then just immediately apply updates. May as well just do TcxGrid -> TDataSource -> TSQLQuery. – Brian Sep 09 '21 at 20:43
  • You do need to create TFields and then specify which is the primary key. – Freddie Bell Sep 10 '21 at 06:17
  • I think your initial problem is that Oracle exception: ORA-01722: invalid number, you have to find what number oracle doesnt like. Most probably generated from SQL Provider UPDATE/DELETE statement isnt correct. – Miroslav Penchev Sep 10 '21 at 11:15
  • @MiroslavPenchev Thank you, do you know how can I capture the SQL generated by the provider? – BaldwinIV Sep 10 '21 at 14:53
  • @BaldwinIV in such cases usually I am debugging with Debug DCU option ON and go inside methods generating SQL statements in Provider, where I can see generated SQL statements, that will help understanding what's wrong with setup of components. Other way is to use some tools for Oracle where you can watch running statements, but I am not familiar with oracle tools. – Miroslav Penchev Sep 13 '21 at 07:36

0 Answers0