Page 1 of 1

Inserting records with ODAC

Posted: Sun 17 Apr 2005 22:19
by Maur1zz10
I have some troubles with odac, I really think that the problem is found in the sql statment, I've searching on the web but I haven't found any example that it has the sql statments written like I want, I have moved the apostrophes for everywhere, it always has an exception.

Luckly someone can help me. : :shock:


TFMiAgenda is a TForm.
DMBDOracle is a TOraSession.
OQMiAgenda is a OraQuery.

This is the source code.

procedure TFMiAgenda.Button1Click(Sender: TObject);
begin
DMBDOracle.OQMiAgenda.CachedUpdates:=true;
DMBDOracle.OQMiAgenda.SQLInsert.Text:='insert into miagenda([Nombre],[Direccion],[Telefono],[Fecha]) values(''miNombre'',''miDireccion'',''numTelefonico'',TO_DATE(''15/08/1984'',''dd/mm/yyyy''))';
try
DMBDOracle.OQMiAgenda.Open;
DMBDOracle.OQMiAgenda.Edit;
DMBDOracle.OQMiAgenda.Insert;
DMBDOracle.OQMiAgenda.Post;
DMBDOracle.OQMiAgenda.Session.StartTransaction;
DMBDOracle.OQMiAgenda.Session.Commit;
DMBDOracle.OQMiAgenda.CommitUpdates;
except
on e:Exception do
ShowMessage('ERROR');
end;
FMiAgenda.Refresh;
end;

Thank's.

Posted: Sun 17 Apr 2005 22:23
by Maur1zz10
By the way, any field is not null.

Posted: Mon 18 Apr 2005 03:25
by Maur1zz10
The exception is launched on
DMBDOracle.OQMiAgenda.Edit;

Posted: Tue 19 Apr 2005 11:08
by Alex
Please don't duplicate your posts in two languages, we accept English topics only.
I think that your problem is in quotation symbols [ in your SQL, pls. try to
use " instead of [ .