Subject RE: [IBO] Insert problem/question upgrading from v4.8
Author Michael Horne

Hello Jason,

 

Below is the dfm text for the Query, showing all flags, and sample code. 

Sorry it has taken so long to get this posted.

 

object qyOrdersM_test: TIB_Query

  IB_Connection = formIBData.cnMain

  SQL.Strings = (

    'SELECT *'

    'FROM ORDERSM'

    'WHERE OM_ID = :ID')

  GeneratorLinks.Strings = (

    'OrdersM.OM_ID=gen_OrdersM_id')

  GetServerDefaults = True

  KeyLinks.Strings = (

    'ORDERSM.OM_ID')

  PessimisticLocking = True

  RequestLive = True

  Left = 248

  Top = 152

end

 

This is code showing the usage and causing the error

 

// this procedure works

procedure TFormOrderMenu.btTestWorksClick(Sender: TObject);

var xOM_ID:Integer;

begin

  try

    qyOrdersM_Test.Close;

    qyOrdersM_Test.Insert;

    xOM_ID := qyOrdersM_Test.FieldByName('OM_ID').AsInteger;

    qyOrdersM_Test.Post;

 

    // 2015-02-09 Added the following to reopen the record we are editing

    qyOrdersM_Test.Close;

    qyOrdersM_Test.ParamByName('ID').AsInteger := xOM_ID;

    qyOrdersM_Test.Open;

 

    qyOrdersM_Test.Edit;

    ShowMessage('Got Here');

    qyOrdersM_Test.Post;

    qyOrdersM_Test.Close;

    ShowMessage('Got Here2');

  except

    on E: Exception do

    begin

      ShowMessage('Error: btTestWorksClick'#13 + '"'+E.Message+'"');

      exit;

    end;

  end;

end;

 

// This procedure throws an exception

procedure TFormOrderMenu.btTestExceptionClick(Sender: TObject);

var xOM_ID:Integer;

begin

  try

    qyOrdersM_Test.Close;

    qyOrdersM_Test.Insert;

    xOM_ID := qyOrdersM_Test.FieldByName('OM_ID').AsInteger;

    qyOrdersM_Test.Post;

 

    ShowMessage('Got Here');

    qyOrdersM_Test.Edit;

    ShowMessage('No Get Here');

    qyOrdersM_Test.Post;

    qyOrdersM_Test.Close;

  except

    on E: Exception do

    begin

      ShowMessage('Error: btTestExceptionClick'#13 + '"'+E.Message+'"');

      exit;

    end;

  end;

end;

 

 

 

 

From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]
Sent: Wednesday, February 11, 2015 1:19 PM
To: IBObjects@yahoogroups.com
Subject: RE: [IBO] Insert problem/question upgrading from v4.8

 

 

One thing that could be a factor is your setting of BufferSynchroFlags.
What is that property set to for that query?

Thanks,
Jason Wharton
www.ibobjects.com


-----Original Message-----
From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]
Sent: Monday, February 9, 2015 11:01 PM
To: IBObjects@yahoogroups.com
Subject: [IBO] Insert problem/question upgrading from v4.8

Hello,

I am upgrading a program from delphi7, ibo v4.8 to the newest ibo v5.5.5.

I have come across a section of code where a query contains

SELECT *

FROM ORDERSM

WHERE OM_ID = :ID

the Delphi code does the following

qyOrdersM.Insert;

xOM_ID := qyOrdersM.FieldByName('OM_ID').AsInteger;

qyOrdersM.FieldByName('OM_CONSOLIDATED_ID').AsInteger:=xOM_ID;

qyOrdersM.FieldByName('OM_CUS_ID').AsInteger := xKeyCustomer;

qyOrdersM.Post;

qyOrdersM.Edit;

the edit is causing an exception of

"Cannot Edit current Row"

I know that the code was working before the upgrade of IBO.

-------------------------------------

I can fix this by inserting the following 3 lines before the "Edit"

qyOrdersM.Close;

qyOrdersM.ParamByName('ID').AsInteger := xOM_ID;

qyOrdersM.Open;

But is this the best way to handle it?

Are there any other problems I am likely to run into while doing the
conversion?

Thanks

Michael Horne

[Non-text portions of this message have been removed]

------------------------------------
Posted by: "Michael Horne" <guardian_yahoo@...>
------------------------------------

__________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
__________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !
http://tracker.ibobjects.com - your portal to submit and monitor bug reports
http://community.ibobjects.com - your portal to purchase and upgrade
------------------------------------

Yahoo Groups Links