Subject | FB API advice |
---|---|
Author | Ivan Prenosil |
Post date | 2004-05-12T19:07:54Z |
I have application that behaves like ISQL (executes commands/scripts)
and use FB API. Everything works well with one exception:
when I execute "SELECT * FROM ..." from some table,
then Alter that table (add new column) from another application (isql),
then "SELECT * ..." again, ->
the second select returns the old unchaged structure.
It is somehow expected behaviour because I am still in the same transaction
(although ISQL returns new structure immediately; why ?) .
What I do not understand is that if I now *commit, *start new transaction
and *execute Select, I still see only old structure !!
Any clue what I am doing wrong ???
Why prepare done in new transaction does see only old metadata ?
(it looks like transaction or prepared statment was stuck somehow,
but I verified that after commit both transaction handle and statement handle were zero)
In this new transaction I can select from system tables, and there I can see
the new column, yet I am not able to prepare any command using that column.
I have to disconnect/connect to be able to use new metadata.
Also, if I add yet another column, than after commit/start_tran I do not see it,
however now I see the previously added column ?!?
Even more strange is that when I execute two Alter Table commands,
than after commit/start_tran I see both their changes normally ?!?
Some other notes:
I use only single transaction, and I do not hold prepared version of command,
i.e. when I say that I execute Select, it consists from these calls
(plus checking status vector after each call, allocating & initializing xsqlda etc.):
- isc_start_transaction(...) (if not started yet);
- isc_dsql_alloc_statement2(status_vector, db, st);
- isc_dsql_prepare(status_vector, tr, st, 0, sql, dialect, out_xsqlda);
- isc_dsql_execute(status_vector, tr, st, 1, nil);
- while (0 = isc_dsql_fetch(status_vector, st, 1, out_xsqlda)) do ...
- isc_dsql_free_statement(status_vector, st, DSQL_drop);
Thanks for any clue,
Ivan
and use FB API. Everything works well with one exception:
when I execute "SELECT * FROM ..." from some table,
then Alter that table (add new column) from another application (isql),
then "SELECT * ..." again, ->
the second select returns the old unchaged structure.
It is somehow expected behaviour because I am still in the same transaction
(although ISQL returns new structure immediately; why ?) .
What I do not understand is that if I now *commit, *start new transaction
and *execute Select, I still see only old structure !!
Any clue what I am doing wrong ???
Why prepare done in new transaction does see only old metadata ?
(it looks like transaction or prepared statment was stuck somehow,
but I verified that after commit both transaction handle and statement handle were zero)
In this new transaction I can select from system tables, and there I can see
the new column, yet I am not able to prepare any command using that column.
I have to disconnect/connect to be able to use new metadata.
Also, if I add yet another column, than after commit/start_tran I do not see it,
however now I see the previously added column ?!?
Even more strange is that when I execute two Alter Table commands,
than after commit/start_tran I see both their changes normally ?!?
Some other notes:
I use only single transaction, and I do not hold prepared version of command,
i.e. when I say that I execute Select, it consists from these calls
(plus checking status vector after each call, allocating & initializing xsqlda etc.):
- isc_start_transaction(...) (if not started yet);
- isc_dsql_alloc_statement2(status_vector, db, st);
- isc_dsql_prepare(status_vector, tr, st, 0, sql, dialect, out_xsqlda);
- isc_dsql_execute(status_vector, tr, st, 1, nil);
- while (0 = isc_dsql_fetch(status_vector, st, 1, out_xsqlda)) do ...
- isc_dsql_free_statement(status_vector, st, DSQL_drop);
Thanks for any clue,
Ivan