Subject | Re: [IBO] update from one database to another |
---|---|
Author | comesailing@btinternet.com |
Post date | 2001-09-27T09:11:57Z |
--- In IBObjects@y..., Svein Erling Tysvær
<svein.erling.tysvaer@k...> wrote:
Thanks Svein. the trouble is that I am lazy! I hate writing out all
those field names for a dsql update statement. I hoped a live cursor
with 'select * ' would do the trick.
I suppose I can work out set 'fields[jj] = values[jj]' for jj from 0
to fieldcount-1 somehow in a dsql ?
Oh of course, I did not mention, but I was trying to write a routine
to cover various tables so I don't know the field-names unless I
gather them into a string-list.
Back to the drawing board !
Thanks Dave.
things up. Use a TIB_DSQL for
SET <field> = <value>
call Execute (or
your transaction(s).
<svein.erling.tysvaer@k...> wrote:
Thanks Svein. the trouble is that I am lazy! I hate writing out all
those field names for a dsql update statement. I hoped a live cursor
with 'select * ' would do the trick.
I suppose I can work out set 'fields[jj] = values[jj]' for jj from 0
to fieldcount-1 somehow in a dsql ?
Oh of course, I did not mention, but I was trying to write a routine
to cover various tables so I don't know the field-names unless I
gather them into a string-list.
Back to the drawing board !
Thanks Dave.
> Hi Dave!of
>
> This should be simple.
>
> >I have tried to open a query on the source table (to get a dataset
> >only the update-needing records). Then going down these records toTIB_Cursor would be preferrable to a TIB_Query. But then you mess
> >eof, at each source record have opened a cursor on destination
> >table , set it in edit mode, copied the fields across one-by-one,
> >then posted the dest table record.
>
> Your start is good, albeit if done without user interaction a
things up. Use a TIB_DSQL for
> your destination table (use a tiCommitted transaction withoutAutoCommit for it), assign an update statement to it (UPDATE <table>
SET <field> = <value>
> WHERE <pk> = <value>), prepare this DSQL, loop through all recordsin source assigning the values to the parameters to your DSQL and
call Execute (or
> ExecSQL). When your finished with all your records (or maybe forevery x records if you're updating very many records) call Commit for
your transaction(s).
>
> HTH,
> Set