We help IT Professionals succeed at work.

Error: 'Operation not applicable'

QurbanDurrani
on
Medium Priority
2,714 Views
Last Modified: 2012-08-13
Hi Experts,
 I am getting an error: "Project abc.exe raised exception class EDBEngineError with message 'Operation not applicable.'. Process stopped. use Step or Run to continue." If I click 'OK' and Click run again, I get the error again but not anymore. Seems like I am getting the error twice but no more. I get this error after "showmessage('43');" and before "showmessage('44');"
Thanks for your help in advance


procedure TMainForm.SerialSheetShow(Sender: TObject);
begin
showmessage('40');
  DMForm.T_Port.Filtered := FALSE;
  with DMForm.Q_PortGrid do
  begin
  showmessage('41');
    if Active then Close;
    if (not DMForm.T_RTU.IsEmpty) and (not DMForm.T_Port.IsEmpty) then
    begin
      showmessage('42');
      SQL.Clear;
      SQL.Add('SELECT port.PortID,port.PortNo,port.Type,typelookup.Typeindex,' +
        'typelookup.TypeString,portlookup.PortIndex,portlookup.PortString ' +
        'FROM port,typelookup,portlookup WHERE ' +
        '(typelookup.TypeIndex = port.Type) AND ' +
        '(portlookup.PortIndex = port.PortNo) AND ' +
        '(port.P$RTUID = ' + DMForm.T_RTURTUID.AsString + ') AND ' +
        '(port.PortNo <= ' + IntToStr(FIRST_SER_EXP + 24) + ')' +
        'ORDER BY port.PortNo');
        showmessage('43');
      Open;
      showmessage('44');
    end;
  end;
  showmessage('20');
  PortGridCellClick(nil);
end;

Open in new window

Comment
Watch Question

Commented:
In this line:
'(port.P$RTUID = ' + DMForm.T_RTURTUID.AsString + ') AND ' +
shouldn't you have quotes or inverted commas, i.e.
'(port.P$RTUID = ' + QuotedStr(DMForm.T_RTURTUID.AsString) + ') AND ' +

You could try putting all your where conditions in one big set of brackets (see attached code below)

Other than that, I don't notice anything. for now...
      SQL.Add('SELECT port.PortID,port.PortNo,port.Type,typelookup.Typeindex,' +
        'typelookup.TypeString,portlookup.PortIndex,portlookup.PortString ' +
        'FROM port,typelookup,portlookup WHERE ' +
        '(' + 
        '(typelookup.TypeIndex = port.Type) AND ' +
        '(portlookup.PortIndex = port.PortNo) AND ' +
        '(port.P$RTUID = ' + DMForm.T_RTURTUID.AsString + ') AND ' +
        '(port.PortNo <= ' + IntToStr(FIRST_SER_EXP + 24) + ')' +
        ')' + 
        'ORDER BY port.PortNo');

Open in new window

Author

Commented:
Just to add, This query has been working fine for a long time.
Thanks.
CERTIFIED EXPERT
Top Expert 2014
Commented:
Depending on the database engine being used, I speculate that it is this part of your SQL:
'(port.P$RTUID = ' + DMForm.T_RTURTUID.AsString + ') AND ' +

In most cases, you will need to compare text columns with a properly delimited value.  You should be able to use quotes or double apostrophe characters, or
QuotedString(DMForm.T_RTURTUID.AsString)

Author

Commented:
I use BDE. As I stated in my question(probably not clearly), During the process of starting the application, The query errors twice, but the third time around, the query works just fine, not to mention that the query has been working fine for a long time. So it seems to me that the problem lies out side the query. My guess is that something is not being set or opened before the first two times the query is executed.

Author

Commented:
I have tried both rtwoolf and aikimark suggestions, still getting the error.
Top Expert 2007

Commented:
procedure TMainForm.SerialSheetShow(Sender: TObject);
begin
showmessage('40');
  DMForm.T_Port.Filtered := FALSE;
  with DMForm.Q_PortGrid do
  begin
  showmessage('41');
    if Active then Close;
    if (not DMForm.T_RTU.IsEmpty) and (not DMForm.T_Port.IsEmpty) then
    begin
      showmessage('42');
      SQL.Clear;
      SQL.Add('SELECT port.PortID,port.PortNo,port.Type,typelookup.Typeindex,' +
        'typelookup.TypeString,portlookup.PortIndex,portlookup.PortString ' +
        'FROM port,typelookup,portlookup WHERE ' +
        '(typelookup.TypeIndex = port.Type) AND ' +
        '(portlookup.PortIndex = port.PortNo) AND ' +
        '(port.P$RTUID = ' + DMForm.T_RTURTUID.AsString + ') AND ' +
        '(port.PortNo <= ' + IntToStr(FIRST_SER_EXP + 24) + ')' +
        'ORDER BY port.PortNo');
        showmessage('43');
      try
         Open;
      except
         on E: Exception do
        begin
           Showmessage(E.Message);
         end;
      end;
      showmessage('44');
    end;
  end;
  showmessage('20');
  PortGridCellClick(nil);
end;

Check what is the message?
 

Author

Commented:
I tried dinilud suggestion, It only shows the old error message. No new error message is shown.
Top Expert 2007

Commented:
Top Expert 2007
Commented:
Try Like This
SQL.Add('SELECT port.PortID,port.PortNo,port.Type,'+
       'typelookup.Typeindex,typelookup.TypeString,'+
       'portlookup.PortIndex,portlookup.PortString  '+
       'FROM port  '+
       'INNER JOIN typelookup ON(typelookup.TypeIndex = port.Type) '+
       'INNER JOIN portlookup ON(portlookup.PortIndex = port.PortNo) '+
       'WHERE (port.P$RTUID = ' + DMForm.T_RTURTUID.AsString + ') AND '+
       '(port.PortNo <= ' + IntToStr(FIRST_SER_EXP + 24) + ')' +
        ')' + 
        'ORDER BY port.PortNo');

Open in new window

Commented:
Yeah have you tried without the line with P$RTUID ?
If there is no error you can at least know the problematic line and then focus on a solution...

as follows...
    begin
      showmessage('42');
      SQL.Clear;
      SQL.Add('SELECT port.PortID,port.PortNo,port.Type,typelookup.Typeindex,' +
        'typelookup.TypeString,portlookup.PortIndex,portlookup.PortString ' +
        'FROM port,typelookup,portlookup WHERE ' +
        '(typelookup.TypeIndex = port.Type) AND ' +
        '(portlookup.PortIndex = port.PortNo) AND ' +
//        '(port.P$RTUID = ' + DMForm.T_RTURTUID.AsString + ') AND ' +
        '(port.PortNo <= ' + IntToStr(FIRST_SER_EXP + 24) + ')' +
        'ORDER BY port.PortNo');
        showmessage('43');
      Open;
      showmessage('44');
    end;

Open in new window

Author

Commented:
The problem is not with the query. It resides somewhere else. My guess is the query is being executed before some of the tables are initialized because the same query works after the application has finished starting up. Thanks to all for your help. I'll split the points up.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.