I am working on a database migration in which we migrate data from 1 table to 2 other tables. For this I use a PL/SQL script. A very simplified version of the script is visible below:
FOR foo IN (SELECT * FROM FOO) LOOP
INSERT INTO BAR (ID, STATUS)
VALUES (foo.ID, foo.STATUS);
FOR foolog IN (SELECT * FROM FOO_LOG where ID = foo.ID) LOOP
INSERT INTO BAR_LOG (ID, REV);
VALUES (FOO_SEQ.CURRVAL, foolog.REV);
The problem is: liquibase runs the script but no data is persisted to the database, it looks as if the script doesn't run. If I introduce a typo on purpose (change a table name for example) the script fails to run so it does actually execute the script. Also, when I run the SQL manually it works as expected so it seems that the problem is related to liquibase.
I found out why it wasn't working and it was a really stupid mistake of myself. Nothing to do with liquibase.
I insert test data through the Intellij Oracle Console. Apparently this Console by default runs everything in a transaction but doesn't commit it automatically. So what happened is that I inserted test data through Intellij, then run the script in liquibase (which didn't find any data because the transaction in Intellij wasn't committed) and then tried to see the result in Intellij. After manually comitting the test data transaction in Intellij everything worked fine.
Leave a comment on Bob1's reply
Change topic type
Link this topic
Provide the permalink of a topic that is related to this topic