I hope someone can help me. The following routine (code follows) is called
a number of times. Depending on whether I leave in the exception or not I
get different error messages. With the exception, it says that p_fname
field is not found( all shown names are valid). Other messages obtained
are 'Cannot perform operation on closed dataset" and "capability not
supported", the later despite the fact that I am following examples of
local SQL.
Any commented out code has been tried as an alternative.
Any input/suggestions would be very much appreciated.
Thanks.
Tom.
Code:
function TfrmSched.GetSchedForEmp(empNum: String): Boolean;
{ returns False if no records exist for given empNum }
const
startDate = '09/05/93';
tempNO = '103';
begin
with queSched do begin
Close;
with sql do begin
Clear;
Add('select h.p_fname,h.p_mi,h.p_lname,');
Add('u.s_start11,u.s_start12,u.s_start13,u.s_start14,u.s_start15,');
Add('u.s_start16,u.s_start17,u.s_stop11,u.s_stop12,');
Add('u.s_stop13,u.s_stop14,u.s_stop15,u.s_stop16,u.s_stop17');
Add('from "hrpersnl" h, "unsched" u');
Add('where h.s_empno = u.s_empno');
{ Add('where u.s_empno = :employee and u.s_date = :Date'); }
{ Add(Format('where u.s_empno = %s and u.s_date = %s',
[tempNo, startDate]));
}
{ Add('where "unsched"."s_empno" = :"employee" and ');
Add('"unsched"."s_date" = :"Date"');
}
end;
{ if not prepared then
Prepare;
}
{ ParamByName('Employee').AsString := tempNo;}
{ Params[1].AsString := startDate;}
try
Open;
except
{ on e:EDatabaseError do begin
MessageDlg(e.message, mtError, [mbOK], 0);
Exit;
end; }
end;
{ Unprepare; }
if (RecordCount > 0) then
Result := True
else
Result := False;
end;
end;
You might want to try copying your SQL statement to the Boreland Database
Desktop and executing it there. I found this helpful in determining why
a query won't work in code. The Desktop's error messages are usually a
little clearer than Delphi itself.
Mike