Subject | Odp: [firebird-support] Can one (repeatedly) res tructure a Firebird table in a single transactio n? |
---|---|
Author | liviuslivius@poczta.onet.pl |
Post date | 2013-03-24T07:37:45Z |
Hi,
You can not do this in one transaction. Especially created field must be commited before fill with data. But what problem with many transaction? Simple solution is to have table with db version and check it in application if it can work with or db is not upgraded. E.g. after creating field b you increse ver by 1 e.g. now it is 7 and commit. then you fill b with data from a inc ver and commit now it is 8. Drop field a inc ver and commit now it is 9. Rename be to a inc ver and commit now it is 10. You only need to check at start of your app if ver=10
Regards,
Karol bieniaszewski
----- Reply message -----
Od: "tvdien@..." <tvdien@...>
Do: <firebird-support@yahoogroups.com>
Temat: [firebird-support] Can one (repeatedly) restructure a Firebird table in a single transaction?
Data: niedz., mar 24, 2013 01:38
Normally, I'd do a relatively complicated change of data type on column A like this:
- Create column B of the new data type
- Set B to contain the new values derived from A
- Drop A
- Rename B to A
To guarantee the validity of my data model, I'd like to perform such restructuring within a single transaction. So far, I have not been able to do that, because, depending on the isolation level, either B is not considered to exist yet, or I'm not allowed to rename B ("update conflicts with concurrent update"), or no errors occur but B is empty. Is it possible to perform to do what I ask - I'd love to see how - or is it absolutely required to COMMIT in between?
P.S. Asked on StackOverflow first, so if you prefer, you might as well answer there: http://stackoverflow.com/q/15591799/1163893
[Non-text portions of this message have been removed]
You can not do this in one transaction. Especially created field must be commited before fill with data. But what problem with many transaction? Simple solution is to have table with db version and check it in application if it can work with or db is not upgraded. E.g. after creating field b you increse ver by 1 e.g. now it is 7 and commit. then you fill b with data from a inc ver and commit now it is 8. Drop field a inc ver and commit now it is 9. Rename be to a inc ver and commit now it is 10. You only need to check at start of your app if ver=10
Regards,
Karol bieniaszewski
----- Reply message -----
Od: "tvdien@..." <tvdien@...>
Do: <firebird-support@yahoogroups.com>
Temat: [firebird-support] Can one (repeatedly) restructure a Firebird table in a single transaction?
Data: niedz., mar 24, 2013 01:38
Normally, I'd do a relatively complicated change of data type on column A like this:
- Create column B of the new data type
- Set B to contain the new values derived from A
- Drop A
- Rename B to A
To guarantee the validity of my data model, I'd like to perform such restructuring within a single transaction. So far, I have not been able to do that, because, depending on the isolation level, either B is not considered to exist yet, or I'm not allowed to rename B ("update conflicts with concurrent update"), or no errors occur but B is empty. Is it possible to perform to do what I ask - I'd love to see how - or is it absolutely required to COMMIT in between?
P.S. Asked on StackOverflow first, so if you prefer, you might as well answer there: http://stackoverflow.com/q/15591799/1163893
[Non-text portions of this message have been removed]