Code: Select all
TABLE1
ID NUMBER,
NAME VARCHAR(20),
DATE_N DATE,
SAL NUMBER
SQLInsert
Code: Select all
insert into ADRH.TABLE1
(ID, NAME, DATE_N,SAL)
values
(:ID, :NAME, :DATE_N, :SAL )
Code: Select all
//
implementation
function ExceptionCode(AException: Exception): String;
begin
Result := Copy(AException.Message, 4, 6);
end;
function IsOracleException(AException: Exception): Boolean;
begin
Result := Copy(AException.Message, 1, 4) = 'ORA-';
end;
Code: Select all
procedure TConceptos.ACEPTClick(Sender: TObject);
begin
try
OraQuery1.Open;
OraQuery1.Append;
OraQuery1.FieldByName('ID').AsInteger:= strtoint(trim(Maskedit1.Text));
OraQuery1.FieldByName('NAME').AsString:= Maskedit2.Text;
OraQuery1.FieldByName('DATE_N').AsDateTime:= strtodate(trim(Maskedit3.Text));
OraQuery1.FieldByName('SAL').AsInteger:= strtoint(trim(Maskedit4.Text));
OraQuery1.Post;
OraQuery1.Session.StartTransaction;
OraQuery1.ApplyUpdates;
OraQuery1.Session.Commit;
OraQuery1.CommitUpdates;
except
on E: Exception do
begin
if IsOracleException(E) then
begin
if ExceptionCode(E) = '-01400' then
E.Message := 'cannot insert NULL';
end;
raise;
end;
end;
end;
inserted NULL in fields NOT NULL with SQL Plus It gives me the error:
ORA-01400: It is not possible to realize an insertion NULL in ("ADRH"."TABLA1"."ID"), But in the delphi says to me Project Project1.exe raised exception class EConvertError with message "" is not a valid integer value' and with Field type DATE The same thing happens......
Can help me to solve my problem??