The test case for this is the following:
SQL for the test table
Code: Select all
CREATE TABLE SMARTTESTTABLE (
PK INTEGER
);
ALTER TABLE SMARTTESTTABLE ADD CONSTRAINT PK_SMARTTESTTABLE PRIMARY KEY (PK);
Code: Select all
program SmartInsertTest;
{$APPTYPE CONSOLE}
{
CREATE TABLE SMARTTESTTABLE (
PK INTEGER
);
ALTER TABLE SMARTTESTTABLE ADD CONSTRAINT PK_SMARTTESTTABLE PRIMARY KEY (PK);
}
{.$DEFINE WITHOUT_SELECT_FROM_SELECT}
uses
Ora, OraSmart;
const
cServer = 'YourServer';
cUserName = 'YourUser';
cPassword = 'YourPassword';
var
S: TOraSession;
Q: TSmartQuery;
begin
S := TOraSession.Create(nil);
try
S.Server := cServer;
S.Username := cUserName;
S.Password := cPassword;
S.ConnectPrompt := False;
Q := TSmartQuery.Create(nil);
try
Q.Session := S;
{$IFDEF WITHOUT_SELECT_FROM_SELECT}
Q.SQL.Add('SELECT * FROM SMARTTESTTABLE');
{$ELSE ~WITHOUT_SELECT_FROM_SELECT}
Q.SQL.Add('SELECT * FROM (SELECT * FROM SMARTTESTTABLE)');
Q.Options.SetFieldsReadOnly := False;
{$ENDIF ~WITHOUT_SELECT_FROM_SELECT}
Q.KeyFields := 'PK';
Q.UpdatingTable := 'SMARTTESTTABLE';
Q.Open;
Q.Append;
Q.FieldByName('PK').AsInteger := 1;
Q.Post;
Q.Append;
Q.FieldByName('PK').AsInteger := 1;
Q.Post;
finally
Q.Free;
end;
finally
S.Free;
end;
end.
- create the table
- create a new console application in Delphi and paste the code
- adjust the constants cServer, cUserName and cPassword
- compile and run the example
expected: ORA-00001 on second post and one record in the DB
actual: no exceptions, but no record in the DB
- remove the first dot in "{.$DEFINE WITHOUT_SELECT_FROM_SELECT}"
- compile and run the example
expected: ORA-00001 on second post and one record in the DB
actual: ORA-00001 on second post and one record in the DB