Guest
April 18, 2012, 3:21am
1
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
username: test
password: test
driver: oracle.jdbc.OracleDriver
classpath: ojdbc5.jar
url: jdbc:oracle:thin:@db02:1521:test1
promptForNonLocalDatabase: false
my changelog file
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd ">
and heres the formatted sql files
[root@zhangvm liquibase]# cd database/test/
[root@zhangvm test]# ls
ta.sql test4.sql test.sql
[root@zhangvm test]# pwd
/root/liquibase/database/test
[root@zhangvm test]# cat *
--liquibase formatted sql
--changeset ta2.sql:1
CREATE TABLE TEST4(
ID INT,
NAME VARCHAR2(20)
);
--liquibase formatted sql
--changeset test4.sql:1
CREATE TABLE TEST4(
ID INT,
NAME VARCHAR2(20)
);
--liquibase formatted sql
--changeset test.sql:1
CREATE TABLE TEST1(
ID INT,
NAME VARCHAR2(20)
);
[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?
Guest
April 18, 2012, 3:21am
3
also,
with formatted sql
while running scripts that i have to create sequences
heres a example
--liquibase formatted sql
--changeset _sequences_test:1
define seq_name=test_sequence
define seq_minvalue=1
define seq_maxvalue=4294967295
define seq_increment=1
define seq_start=1
WHENEVER SQLERROR CONTINUE;
column next_value new_value seq_start noprint;
SELECT &&seq_name..nextval next_value FROM dual;
DROP SEQUENCE &&seq_name;
WHENEVER SQLERROR EXIT FAILURE;
CREATE SEQUENCE &&seq_name
MINVALUE &&seq_minvalue
MAXVALUE &&seq_maxvalue
START WITH &&seq_start
INCREMENT BY &&seq_increment
CYCLE
;
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?
Guest
April 18, 2012, 3:21am
4
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
create table tableone ( i number(20), str varchar2(20))
/
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
Guest
April 18, 2012, 3:21am
5
didnt know these where SQL*plus specific commands
never mind