Starr, Thomas
2009-01-30 19:13:00 UTC
Hi folks - I need to confirm whether one should be able to use either
update or updateSQL where <sqlFile=> in the change log references a file
containing anonymous plsql block (or a trigger).
Also whether update and updateSQL should both work with the same
anonymous block (or trigger) instead enclosed in <sql></sql> tags in the
change log.
This is the environment:
CLASSPATH gets the jdbc driver here:
/xxx/app/oracle/product/10.2.0/client/jdbc/lib/classes12.zip
JAVA_HOME is: /usr/java/jdk1.5.0_16
I find it works fine to use either update or updateSQL to create tables
/ foreign keys etc via Liquibase internals.
And it works fine to use updateSQL where <sqlFile=> in the change log
points to a file containing an anonymous block (or trigger).
But using update with the same change log so Liquibase will execute
directly fails.
I.e. - With this change log
(anon_block_external_file_change_log_errors.xml):
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<changeSet id="9" author="tom">
<sqlFile path="anon_block_external_file.sql"/>
</changeSet>
</databaseChangeLog>
Referencing this file (anon_block_external_file.sql):
DECLARE
v_num NUMBER;
v_exc EXCEPTION;
PRAGMA EXCEPTION_INIT (v_exc,-01418);
BEGIN
EXECUTE IMMEDIATE 'DROP INDEX blah';
EXCEPTION
WHEN v_exc THEN
DBMS_OUTPUT.PUT_LINE('Caught exception printed message');
END;
/
This fails with Migration Failed: Error executing SQL DECLARE:
java -jar /xxxxxx/liquibase/liquibase-1.9.0/liquibase-1.9.0.jar \
--defaultsFile=/xxxxxx/liquibase/liquibase-1.9.0/samples/playpen/liquiba
se.oracle.properties.xxx.xxxxxx \
--changeLogFile=anon_block_external_file_change_log_errors.xml \
--url=jdbc:oracle:thin:@xxxxxx.dev:1234:xxx \
--driver=oracle.jdbc.OracleDriver \
update
But this migrates reliably using the same change log and executing the
resulting output file is successful:
java -jar /xxxxxx/liquibase/liquibase-1.9.0/liquibase-1.9.0.jar \
--defaultsFile=/xxxxxx/liquibase/liquibase-1.9.0/samples/playpen/liquiba
se.oracle.properties.xxx.xxxxxx \
--changeLogFile=anon_block_external_file_change_log_errors.xml \
--url=jdbc:oracle:thin:@xxxxxx:1234:xxx \
updateSQL > anon_block_external_file_change_log_errors.sql
On the second question, using either update or updateSQL with this
change log having the same anonymous block (or trigger) in <sql></sql>
fails:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<changeSet id="7" author="tom">
<sql>
DECLARE
v_num NUMBER;
v_exc EXCEPTION;
PRAGMA EXCEPTION_INIT (v_exc,-01418);
BEGIN
EXECUTE IMMEDIATE 'DROP INDEX blah';
EXCEPTION
WHEN v_exc THEN
DBMS_OUTPUT.PUT_LINE('Caught exception printed message');
END;
</sql>
</changeSet>
</databaseChangeLog>
Thanks in advance for any thoughts or clues!!
Tom
update or updateSQL where <sqlFile=> in the change log references a file
containing anonymous plsql block (or a trigger).
Also whether update and updateSQL should both work with the same
anonymous block (or trigger) instead enclosed in <sql></sql> tags in the
change log.
This is the environment:
CLASSPATH gets the jdbc driver here:
/xxx/app/oracle/product/10.2.0/client/jdbc/lib/classes12.zip
JAVA_HOME is: /usr/java/jdk1.5.0_16
I find it works fine to use either update or updateSQL to create tables
/ foreign keys etc via Liquibase internals.
And it works fine to use updateSQL where <sqlFile=> in the change log
points to a file containing an anonymous block (or trigger).
But using update with the same change log so Liquibase will execute
directly fails.
I.e. - With this change log
(anon_block_external_file_change_log_errors.xml):
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<changeSet id="9" author="tom">
<sqlFile path="anon_block_external_file.sql"/>
</changeSet>
</databaseChangeLog>
Referencing this file (anon_block_external_file.sql):
DECLARE
v_num NUMBER;
v_exc EXCEPTION;
PRAGMA EXCEPTION_INIT (v_exc,-01418);
BEGIN
EXECUTE IMMEDIATE 'DROP INDEX blah';
EXCEPTION
WHEN v_exc THEN
DBMS_OUTPUT.PUT_LINE('Caught exception printed message');
END;
/
This fails with Migration Failed: Error executing SQL DECLARE:
java -jar /xxxxxx/liquibase/liquibase-1.9.0/liquibase-1.9.0.jar \
--defaultsFile=/xxxxxx/liquibase/liquibase-1.9.0/samples/playpen/liquiba
se.oracle.properties.xxx.xxxxxx \
--changeLogFile=anon_block_external_file_change_log_errors.xml \
--url=jdbc:oracle:thin:@xxxxxx.dev:1234:xxx \
--driver=oracle.jdbc.OracleDriver \
update
But this migrates reliably using the same change log and executing the
resulting output file is successful:
java -jar /xxxxxx/liquibase/liquibase-1.9.0/liquibase-1.9.0.jar \
--defaultsFile=/xxxxxx/liquibase/liquibase-1.9.0/samples/playpen/liquiba
se.oracle.properties.xxx.xxxxxx \
--changeLogFile=anon_block_external_file_change_log_errors.xml \
--url=jdbc:oracle:thin:@xxxxxx:1234:xxx \
updateSQL > anon_block_external_file_change_log_errors.sql
On the second question, using either update or updateSQL with this
change log having the same anonymous block (or trigger) in <sql></sql>
fails:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<changeSet id="7" author="tom">
<sql>
DECLARE
v_num NUMBER;
v_exc EXCEPTION;
PRAGMA EXCEPTION_INIT (v_exc,-01418);
BEGIN
EXECUTE IMMEDIATE 'DROP INDEX blah';
EXCEPTION
WHEN v_exc THEN
DBMS_OUTPUT.PUT_LINE('Caught exception printed message');
END;
</sql>
</changeSet>
</databaseChangeLog>
Thanks in advance for any thoughts or clues!!
Tom