Subject I am not able to change the primary key
Author

I am not able to change the primary key value from any table using the method below. Am I doing something wrong?

I'm using the evaluation version 5.5.3



procedure TForm1.Button1Click(Sender: TObject);

var

  DB : TIBODatabase;

  T : TIBOTransaction;

  Q : TIBOQuery;

begin

  DB  := TIBODatabase.Create(nil);

  T   := TIBOTransaction.Create(nil);

  Q   := TIBOQuery.Create(nil);

  try

    try

      DB.Params.Add('SERVER=127.0.0.1');

      DB.Params.Add('PATH=C:\Any_Firebird_BD.FDB');

      DB.Params.Add('CHARACTER SET=ISO8859_1');

      DB.Params.Add('SQL DIALECT=3');

      DB.Params.Add('PAGE SIZE=4096');

      DB.Params.Add('PROTOCOL=TCP/IP');

      DB.Params.Add('USER NAME=SYSDBA');

      DB.Params.Add('PASSWORD=masterkey');


      T.IB_Connection   := DB;

      Q.IB_Connection   := DB;

      Q.IB_Transaction  := T;


      Q.SQL.Text := 'UPDATE ANY_TABLE SET ID = :ID WHERE ID = :OLD_ID';


      T.StartTransaction;

      Q.Close;

      Q.ParamByName('ID').AsInteger      := 2;

      Q.ParamByName('OLD_ID').AsInteger  := 1;

      Q.ExecSQL; //RowsAffected = 0 

      T.Commit;


      ShowMessage('OK is show, but doesn´t change the PK!');

    except

      on E: Exception do

        ShowMessage(E.Message);

    end;

  finally

    FreeAndNil(Q);

    FreeAndNil(T);

    FreeAndNil(DB);

  end;

end;