Subject Re: [IBO] More TIB_DataPump questions
Author mspencewasunavailable
--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@...> wrote:
>
> At 11:37 AM 16/08/2006, you wrote:
> >I've been able to get this to work fine as long as I'm doing a
> >straight copy from one TIB_Query to another.
> >
> >Now, I'm trying to set one of the fields to a constant value if
it's
> >zero. I'm using code like this:
> >
> > IB_DataPump1.DstRow.ByName('SESSION_ID').AsInteger := 123;
> >
> >I've tried doing this in AfterFetchRow, BeforeExecuteItems and
> >AfterExecuteItems, but none of these places worked.
> >
> >
> >1) If the source (not the destination, but the source) doesn't
have
> >this field, then the destination doesn't either, even though it's
in
> >the SQL so I get an exception.
> >
> >2) If I provide it in the source, then the value it has in the
> >source is what I always get.
> >
> >I tried AfterFetchRow because of something I read in the help file
> >that implied that this was where one could override mappings. I
> >even tried changing the row data passed into the event, but I got
> >a "read only dataset" exception.
> >
> >The other two where shots in the dark. According to the debugger
> >the value gets changed, but when the row is viewed in the
database,
> >the original value from the source is in the field, not what I
> >supplied.
> >
> >What am I overlooking?
>
> You're trying too hard. Let the database engine do the
walking. :-)
>
> Simply make it an output field in your source query.
>
> select
> fielda,
> fieldb,
> fieldc,
> '12345' as mysessionid
> from blah
> where.....
>
> In this example, the constant comes through as a varchar(5).
Adapt
> your statement to make sure your constant's type is compatible
with
> the destination column it's mapped to and you're done.
>
> Helen
>

This query is constant. Although I don't prepare it and reuse it,
and making a new SQL string each time is not really a big deal, I
could see that it might be in other situations. The results of the
query go to a temporary table for additional processing, so I wanted
to add a unique, per-instance number in a new column when I pumped
the data into the table. It seemed to me to be a more elegant
solution to introduce the session ID at that point, since it's just
there to emulate a temp. table.

If there's no other way, then I'll just produce a new SQL string for
the query each time, incorporating the session ID, but surely this
is what the DataPump's events are for? Would making a custom DPItem
class be another way to do this?


------------------------
Michael D. Spence
Mockingbird Data Systems, Inc.