some issues with formatted sql statements

Hi,

im trying out the formatted sql statements as a way to manage my database since i already have written sql scripts.

and im running into some trouble getting them to run.


so heres my liquibase.properties file

  1. username: test
  2. password: test
  3. driver: oracle.jdbc.OracleDriver
  4. classpath: ojdbc5.jar
  5. url: jdbc:oracle:thin:@db02:1521:test1
  6. promptForNonLocalDatabase: false

my changelog file 

  1. <databaseChangeLog
  2.     xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.     xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
  5.     xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
  6.     http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
and heres the formatted sql files 
  1. [root@zhangvm liquibase]# cd database/test/
  2. [root@zhangvm test]# ls
  3. ta.sql  test4.sql  test.sql
  4. [root@zhangvm test]# pwd
  5. /root/liquibase/database/test
  6. [root@zhangvm test]# cat *
  7. --liquibase formatted sql

  8. --changeset ta2.sql:1

  9. CREATE TABLE TEST4(
  10.         ID INT,
  11.         NAME VARCHAR2(20)
  12. );
  13. --liquibase formatted sql


  14. --changeset test4.sql:1

  15. CREATE TABLE TEST4(
  16.         ID INT,
  17.         NAME VARCHAR2(20)
  18. );
  19. --liquibase formatted sql

  20. --changeset test.sql:1

  21. CREATE TABLE TEST1(
  22.         ID INT,
  23.         NAME VARCHAR2(20)
  24. );
  25. [root@zhangvm test]# 

the problem here is that when i run the script with 

java -jar liquibase --changeLogFile=change.xml update

the output tells me its sucessful but no table is created


also no rows are added into DATABASECHANGELOG table


is it something i did wrong?


You shouldn’t need to keep repeating the --liquibase formatted sql line, just have it at the beginning of each file.


Also, the format of the --changeset command is : not :. That shouldn’t cause it to not work, though.



Does it work to not use but just use for each .sql file?


also,

with formatted sql


while running scripts that i have to create sequences 

heres a example 

  1. --liquibase formatted sql


  2. --changeset _sequences_test:1
  3. define seq_name=test_sequence
  4. define seq_minvalue=1
  5. define seq_maxvalue=4294967295
  6. define seq_increment=1
  7. define seq_start=1

  8. WHENEVER SQLERROR CONTINUE;
  9. column next_value new_value seq_start noprint;
  10. SELECT &&seq_name..nextval next_value FROM dual;
  11. DROP SEQUENCE &&seq_name;

  12. WHENEVER SQLERROR EXIT FAILURE;
  13. CREATE SEQUENCE &&seq_name
  14.   MINVALUE &&seq_minvalue
  15.   MAXVALUE &&seq_maxvalue
  16.   START WITH &&seq_start
  17.   INCREMENT BY &&seq_increment
  18.   CYCLE
  19.   ;
i get a bunch of invalid SQL errors

with the define on top, the WHENEVER SQLERROR CONTINUE/EXIT FAILURE

and substitution.

am i just doing it wrong?

i found the error


it turns out if the author contain any special characters(?) it will refuse to read the changelog

if i use include it still doesnt work


the reason i had  filename as author is because i have hundreds of files and if i have my script set the author to me i might run into collisions with names 


i ended up changing the ‘.’ to _ and it worked fine



Hoever i seem to found more things…


for instance i have some scripts that look like

  1. create table tableone ( i number(20), str varchar2(20))
  2. /
it gives me a error i think because of the /

same thing seems to happen with ’ ; ’ on a new line, but semi colon works well if its put on the same line as a command



didnt know these where SQL*plus specific commands 


never mind