Я получаю ошибки из-за изменений в коде триггера:
liquibase.exception.DatabaseException: Error executing SQL END IF: ORA-00900: ugyldig SQL-setning
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:104)
at liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:1075)
at liquibase.database.AbstractDatabase.executeStatements(AbstractDatabase.java:1059)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:317)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
at liquibase.Liquibase.update(Liquibase.java:113)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:244)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:549)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at elling.ui.JettyRunner.run(JettyRunner.java:14)
at elling.ui.JettyRunner.main(JettyRunner.java:19)
Caused by: java.sql.SQLSyntaxErrorException: ORA-00900: ugyldig SQL-setning
Мой sql такой:
--liquibase отформатированный sql
--changeset martin.raczkowski:2011-11-24-SP2_2_5.sql
DROP TABLE ADRESSE cascade constraints;
CREATE TABLE ADRESSE
(
ID NUMBER,
PERSON_ID NUMBER,
GATEADRESSE1 VARCHAR2(256 BYTE),
GATEADRESSE2 VARCHAR2(256 BYTE),
POSTNUMMER VARCHAR2(20 BYTE),
POSTSTED VARCHAR2(256 BYTE),
ADRESSETYPE VARCHAR2(20 BYTE),
TIDENDRET DATE,
SAKSBEHANDLER VARCHAR2(20 BYTE),
BYDEL VARCHAR2(20 BYTE),
ENHET VARCHAR2(20 BYTE),
CONSTRAINT ADRESSE_PK PRIMARY KEY
(
ID
)
ENABLE
);
CREATE OR REPLACE TRIGGER ADRESSE_ID_TR
BEFORE INSERT ON ADRESSE
FOR EACH ROW
BEGIN
F (new.ID IS NULL) THEN
SELECT adresse_seq.NEXTVAL
FROM dual;
END IF;
END ADRESSE_ID_TR;
Мой db-changelog.xml: (триггеры в .xml файле работают хорошо, те, которые я вставил в .sql, не работают)
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
<changeSet id="2011_11_24_SP1_2" author="martin.raczkowski" context="test">
<validCheckSum>3:8769984ba2d1cba936dc212d944d3582</validCheckSum>
<comment>
Opprett tabeller person, adresse..
</comment>
<sqlFile path="liquibase/2011_11_24_SP1_2.sql" />
</changeSet>
<changeSet id="2011_11_29_SP2_2_1" author="martin.raczkowski" context="test" >
<validCheckSum>3:bf2b156fbb7d29fe58defe8bc4600a09</validCheckSum>
<comment>
Rename kolonner og droppe kolonner. Laget trigger paa Person og Adresse.
</comment>
<sqlFile path="liquibase/2011_11_29_SP2_2_1.sql" />
</changeSet>
<changeSet id="2011_11_30_SP2_2" author="david.carlsson" context="test" >
<validCheckSum>3:a88cdfb1b3e60119f2981c0f30ab7ac9</validCheckSum>
<comment>
Opprett key triggers for Person og Adresse
</comment>
<createProcedure>
CREATE OR REPLACE TRIGGER PERSON_ID_TR
BEFORE INSERT ON PERSON
FOR EACH ROW
WHEN (new.ID IS NULL)
BEGIN
SELECT person_seq.NEXTVAL
INTO :new.ID
FROM dual;
END;
</createProcedure>
</changeSet>
<changeSet id="2011_11_30_SP2_2_2" author="martin.raczkowski" context="test" >
<validCheckSum>3:d2c3da4e48f183e5d523efa675786c53</validCheckSum>
<comment>
Henvendelse tabell oprettes og setter paa sekvens og trigger paa person og adresse.
</comment>
<sqlFile path="liquibase/2011_11_30_SP2_2_2.sql" />
</changeSet>
<changeSet id="2011_11_30_SP2_2_3" author="martin.raczkowski" context="test" >
<comment>
Trigger Henvendelse_id_tr på henvendelse
</comment>
<sqlFile path="liquibase/2011_11_30_SP2_2_3.sql" />
</changeSet>
<changeSet id="2011_11_30_SP2_2_4" author="martin.raczkowski" context="test" >
<comment>
Opprett key triggers for henvendelse
</comment>
<createProcedure>
CREATE OR REPLACE TRIGGER HENVENDELSE_ID_TR
BEFORE INSERT ON HENVENDELSE
FOR EACH ROW
WHEN(new.ID IS NULL)
BEGIN
SELECT henvendelse_seq.NEXTVAL
INTO :new.ID
FROM dual;
END;
</createProcedure>
<createProcedure>
CREATE OR REPLACE TRIGGER HENVENDELSE_BEFORE_INSERT_TR
BEFORE INSERT ON HENVENDELSE
FOR EACH ROW
BEGIN
:new.OPPRETTET := sysdate;
:new.SISTENDRET := sysdate;
END;
</createProcedure>
<createProcedure>
CREATE OR REPLACE TRIGGER HENVENDELSE_AFTER_INSERT_TR
BEFORE INSERT ON HENVENDELSE
FOR EACH ROW
BEGIN
:new.OPPRETTET := sysdate;
:new.SISTENDRET := sysdate;
END;
</createProcedure>
</changeSet>
<changeSet id="2011_12_15_SP2_2_5" author="martin.raczkowski" context="test" >
<comment>
Adresse tabell oppgradert
</comment>
<sqlFile endDelimiter="/" path="liquibase/2011_12_15_SP2_2_5.sql" />
</changeSet>
</databaseChangeLog>