Subject | Re: [IBO] Sync an inserted record with ID provided by a SP, any trick? |
---|---|
Author | Marco Menardi <mmenaz@lycosmail.com> |
Post date | 2003-02-20T21:27:23Z |
I've solved the probelm with a fake field in the select, and an
additional parameter (IN_INSERT) in the SP.
I've tried something like your solution, thinking that passing a
negative ID (I just invert the sign of the returned id) to the SP
could have meant "hei, this is the id, and it's negative since I'm
inserting, revert to positive and do the insert", but does not work,
since then IBO tries to locate the record with the negative ID, and
changing the Buffer in AfterPost does not work (seems that the ID does
not change).
In any case, thanks a lot for your reply.
Just wondering, in a general issue, if IBO could need an improvement
in this regard.
In addition with IB_Grid with a bottom line suitable for totals, and
calculated fields that can be edited (and so store information
regarding the row that don't need to be "persistent") are the most
wanted IBO improvements for me (I remember Jason asked about community
idea about further IBO improvements... Jason, are you reading?)
regards
Marco Menardi
additional parameter (IN_INSERT) in the SP.
I've tried something like your solution, thinking that passing a
negative ID (I just invert the sign of the returned id) to the SP
could have meant "hei, this is the id, and it's negative since I'm
inserting, revert to positive and do the insert", but does not work,
since then IBO tries to locate the record with the negative ID, and
changing the Buffer in AfterPost does not work (seems that the ID does
not change).
In any case, thanks a lot for your reply.
Just wondering, in a general issue, if IBO could need an improvement
in this regard.
In addition with IB_Grid with a bottom line suitable for totals, and
calculated fields that can be edited (and so store information
regarding the row that don't need to be "persistent") are the most
wanted IBO improvements for me (I remember Jason asked about community
idea about further IBO improvements... Jason, are you reading?)
regards
Marco Menardi
--- In IBObjects@yahoogroups.com, "Brian K. Woods" <brian@e...> wrote:
> Marco,
>
> > I have a query that returns a left joined dataset and uses a stored
> > procedure in the EditSQL.
> > This is because the join creates an "empty table" that in IB_Grid I
> > can fill, and the stored procedure checks if the primary_id is not
> > null, then it's an update, otherwise it's an edit.
> > The problem is that I can't get the primary_id in advance as usual,
> > but since I need the buffer to be synchronized after the edit
> > (SyncAfterEdit) and if I "edit" an empty row I've no primary key to do
> > the sync, I'm in troubles :(
> > Is there any property/trick to add to my stored procedure the
>
> I had a similar problem to overcome - don't know if you can use what
I did
> or
> not, but here it is. Your edit sp needs the null value to distinguish
> between
> edit/insert, right? What if you had a negative key value to indicate
> inserts?
> By default, generators start with a value of zero, so if you didn't
change
> it when
> you created the database, then every generated key in your db should
> positive, right?
> So, just create a dummy _reverse_ generator in your db. Don't let IBO's
> generatorlink fetch its values.
> Instead, fetch values from it yourself, passing a -1 for the increment
> parameter.
> Then, when your sp sees the negative value, it can fetch a "real"
generator
> value for the
> new record, just as it currently does when it sees null keys.
>
> Just an idea...
> HTH,
> Brian