Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting EDBEngineError - Operation Not Applicable in Delphi XE2 on ExecSQL Statement

I am using TQuery to insert record into table. Below is the code for that.

with qryABC do
    begin
      Close;
      SQL.Clear;
      SQL.Text := 'INSERT INTO tableXYZ (ID) values (:ID)';
      ParamByName('ID').Value := AnyID;
      ExecSQL;
      Close;
    end;

When I fire same query from oracle, query gets fired, but giving exception when I try to fire the query from delphi xe2. While debugging, I found out that I get error on "ExecSQL" statement in above code. Exception is: EDBEngineError - Operation Not Applicable

I googled it but with no fruit. Please help.


1 Answers

What is AnyID ? With questions like this better to show datatype declaration and value assigned.

As a general suggestion - don't use .Value, try ParamByName('ID').AsInteger or ParamByName('ID').AsString or what u actually need that certain parameter to be.

Not only that would be faster but it also produces more determinate code with compile-time type checking, rather than significantly slower and much less predictable runtime dynamic Variant datatype conversions.

This applies to Fields as well as too Parameters.

like image 56
Arioch 'The Avatar answered Dec 11 '25 15:12

Arioch 'The



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!