Subject RE: [IBO] I am not able to change the primary key
Author IBO Support List
I looked into this and discovered this problem is due to a bug in IBO that was introduced when I tightened up the logic on the OLD_ parameter name prefix issue. This change caused your two parameters to be treated as duplicate parameters as if there wasn't the OLD_ prefix on the second parameter. This is why they always had the same value instead of each of them having the value from your code.
 
You could also have changed :ID to :IDx and it would have prevented the problem too.
 
I have fixed this and so it won't be a problem in my next release of IBO.
 
Thanks for reporting this and sorry for the hassle.
 
Kind regards,
Jason Wharton
 


From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]
Sent: Tuesday, November 11, 2014 11:59 AM
To: IBObjects@yahoogroups.com
Subject: [IBO] I am not able to change the primary key

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;