Can I run an SQL file in Liquibase which contains file reference? - sql

I am using Oracle SQL and Maven.
I'd like to run the following file:
drop table my_table;
/
create table my_table (
id number(20,0) not null,
text varchar2(3000char) not null
)
/
comment on table my_table is 'This is just a test table to see whether the comments could be written to a table';
/
comment on column my_table.id is 'This is the ID';
/
comment on column my_table.text is 'Here should be some text';
/
#..\db\changelog\my_package.pck
/
my_package.pck is:
CREATE OR REPLACE PACKAGE MY_PACKAGE AS
gc_my_date constant date := to_date('2000.01.01', 'yyyy.mm.dd');
function get_my_date return date;
END;
/
CREATE OR REPLACE PACKAGE BODY MY_PACKAGE AS
function get_get_my_date return date AS
BEGIN
RETURN gc_my_date;
END;
END;
/
The file where I gave the location of the SQL file I'd like to be executed:
<?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"
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.6.xsd
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.6.xsd ">
<changeSet author="liquibase-docs" id="sqlFile-example_2.1" runOnChange="true">
<sqlFile dbms="!oracle"
encoding="UTF-8"
endDelimiter="/"
path="../db/changelog/try.sql"
relativeToChangelogFile="true"
/>
</changeSet>
</databaseChangeLog>
The table was created, however, the package not. I run the file of the package with other variable names but after trying to run from liquibase, it didn't changed.
Is there any way to run SQL files in an SQL file. which's direction is written in the way #..\<location of file>?

Related

The Liquibase Exception: unterminated dollar-quoted string at or near

I can't get my function to work in the liquibase changeset.
This function is good working on the IntelliJ IDEA:
CREATE OR REPLACE FUNCTION get_value() RETURNS varchar AS
$$
SELECT varchar '170d76f83d90ea1427' AS result;
$$ LANGUAGE SQL;
But it fails when trying to run it in the liquibase changeset like this:
<changeSet author="akulik" id="test-014-002">
<sql>
CREATE OR REPLACE FUNCTION get_value() RETURNS varchar AS
$$
SELECT varchar '170d76f83d90ea1427' AS result;
$$ LANGUAGE SQL;
</sql>
<rollback>
<sql>
DROP FUNCTION get_secret();
</sql>
</rollback>
</changeSet>
I'm catching this exception:
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.2.2:update (default-cli) on project my_liquibase_project: Error setting up or running Liquibase: Migration failed for change set db/com/akulik/test/db/changesets/db.changelog-014.xml::test-014-002::akulik:
[ERROR] Reason: liquibase.exception.DatabaseException: Error executing SQL CREATE OR REPLACE FUNCTION get_secret() RETURNS varchar AS
[ERROR] $$
[ERROR] SELECT varchar '170d76f83d90ea1427' AS result: ERROR: unterminated dollar-quoted string at or near "$$
[ERROR] SELECT varchar '170d76f83d90ea1427' AS result"
[ERROR] Position: 68
[ERROR] ->
I think that I should correctly shield my function. I tried this way but it didn't work and I received the same error message.
I continue to find a solution in this way.
<changeSet author="akulik" id="test-014-002">
<sql><![CDATA[
CREATE OR REPLACE FUNCTION get_value() RETURNS varchar AS
$$
SELECT varchar '170d76f83d90ea1427' AS result;
$$ LANGUAGE SQL;
]]></sql>
<rollback>
<sql>
DROP FUNCTION get_secret();
</sql>
</rollback>
</changeSet>
I found out about <createProcedure> tag and used it instead of <sql> tag in my changeset definition. That's resolved my problem. Now it's working fine.

Use v('APP_USER') as default value for column in Oracle Apex

I am trying to use v('APP_USER') as default value for a column. I get null when I use it in select like
select v('APP_USER') from dual;
But when I use it as default in column, like below, I am getting error.
create table test_table (col_1 varchar2(50) default NVL(v('APP_USER'), SYS_CONTEXT('USERENV','OS_USER')));
Error
create table test_table (col_1 varchar2(50) default NVL(v('APP_USER'), SYS_CONTEXT('USERENV','OS_USER')))
Error report -
ORA-04044: procedure, function, package, or type is not allowed here
04044. 00000 - "procedure, function, package, or type is not allowed here"
*Cause: A procedure, function, or package was specified in an
inappropriate place in a statement.
*Action: Make sure the name is correct or remove it.
Can anyone explain this or have a turnaround for this ??
There are other options than V('APP_USER'). Since Apex 5, the APP_USER is stored in the sys_context and that is a lot more performant than the V() function. It is available as SYS_CONTEXT('APEX$SESSION','APP_USER').
It also works as a default value for tables:
create table test_table
(col_1 VARCHAR2(100) DEFAULT SYS_CONTEXT('APEX$SESSION','APP_USER'));
Table TEST_TABLE created.
That being said, the best practice for audit columns is a trigger that populates the the 4 audit columns (as #Littlefoot suggested). Have a look at quicksql (under SQL Workshop > Utilities or on livesql.oracle.com). You can have it generate the triggers for you if you set "include Audit columns" and "Apex Enabled". An example of such a generated trigger is:
create or replace trigger employees_biu
before insert or update
on employees
for each row
begin
if inserting then
:new.created := sysdate;
:new.created_by := nvl(sys_context('APEX$SESSION','APP_USER'),user);
end if;
:new.updated := sysdate;
:new.updated_by := nvl(sys_context('APEX$SESSION','APP_USER'),user);
end employees_biu;
/
One option is to use a database trigger, e.g.
CREATE OR REPLACE TRIGGER trg_biu_test
BEFORE INSERT OR UPDATE ON test
FOR EACH ROW
BEGIN
:new.col1 := v ('APP_USER');
END;
/

Component must be declared error (ORA-06550)

Im getting this error:
ORA-06550:line 1, column 25:PLS-00302: component PA_EXCEPTION_LIST_UPDATE must be declared: line1, column 7:PL/SQL: Statement ignored.
I can't figure out what i did wrong.
PROCEDURE Pa_exception_list_update (p_ceid collection_entities.ceid%TYPE,
p_idusr users.idusr%TYPE
)
IS
v_idusr users.idusr%TYPE;
v_ceid collection_entities.ceid%TYPE;
BEGIN
INSERT INTO pa_exception_list(pa_exception_list_id,
ceid,
creation_date,
created_by)
VALUES(pa_exception_list_seq.nextval, p_ceid, SYSDATE, p_idusr);
END Pa_exception_list_update;
It looks like you are calling the procedure before it has been declared.
Look at this example.
Procedure A calls procedure B. But B is unknown at that moment.
create or replace package test is
begin
end test;
create or replace package body test is
procedure a
is
begin
b;
end;
procedure b is
begin
-- do someting
end;
end test;
Solution. Change the order of the procedures within the package or place the procedure in the package specification.
create or replace package test is
begin
procedure b;
end test;
create or replace package body test is
procedure a
is
begin
b;
end;
procedure b is
begin
-- do someting
end;
end test;
According error message the error appears at line 1.
In case this is a stand-alone procedure you must write like create or replace procedure Pa_exception_list_update ...
In case this is part of a PL/SQL Package then you must write like
CREATE OR REPLACE PACKAGE BODY <package name> AS
procedure Pa_exception_list_update ...
I think you are missing something when you declare.
p_ceid IN collection_entities.ceid%TYPE,
p_idusr IN users.idusr%TYPE
I also faced the same problem.
After checking I found that, the procedure i was calling did not exist in the package!.
Later changed the procedure name and it worked.

How can i use max.retry.count in liquibase

In order to use retry.attempts in liquibase :
<sql>ALTER TABLE t set t.name = 'CI_CASE' where t.retry_attempts >= 1000</sql>
not sure how can i ADD a Column to table CI_CASE
so i tried a simpler statement:
<sql>ALTER TABLE CI_CASE ADD COLUMN TNUM</sql>
but i get Exception:
liquibase.exception.DatabaseException: Error executing SQL ALTER TABLE CI_CASE ADD COLUMN TNUM: ORA-00904: : invalid identifier
I have tried appending ";" semicolon, and trying:
<sql>ALTER TABLE t set t.name = 'CI_CASE' and t.column = 'TNUM' where t.retry_attempts >= 1000</sql>
which is my ultimate Goal , is to use retry.attempts for liquibase
so the error was due to Syntax, and the following SQL statement in the .sql file passed:
ALTER TABLE CI_CASE ADD TNUM varchar2(1) NOT NULL;
Now need to figure out how to use :
put ‘max.retry.count’ in to liquibase.property file.
e.g parameter.max.retry.count=30
perhaps as an argument, to the :
<sqlFile path="oracle/schemas/ci_case.sql"/>
i tried:
ALTER TABLE CIS_CASE ADD TNUM varchar2(1) NOT NULL WHERE CIS_CASE.retry_attempts >= ${max.retry.count};
Liquibase update Failed: Migration failed for change set edata-changelog.xml::2016-08-25-cnwill::CW:
00:03:34.886 Reason: liquibase.exception.DatabaseException: Error executing SQL ALTER TABLE CIS_CASE ADD TNUM varchar2(1) NOT NULL WHERE CIS_CASE.retry_attempts >= $ax.retry.count}: ORA-01735: invalid ALTER TABLE option
notice the { and m , missing in the error log, not sure why is that so ?
i tried:
for Database/oracle/schemas/eldata/eldata-changelog.xml
<changeSet id="2016-08-25-cna-01" author="Ch Wills">
<comment>
Testing retry logic on liquibase
</comment>
<sqlFile path="oracle/schemas/eldata/2016-08/2016-08-25-cna-01/20160825_01_upd-data-elis2data-cis_case_kr.sql"/>
</changeSet>
This works, but now we want to incorporate a variable max.retry.count
So I use the property file:
liquibase.property
With:
parameter.max.retry.count=30
And call this in the changeset as:
<changeSet id="2016-08-25-cna-01" author="Ch Wills">
<comment>
Testing retry logic on liquibase
</comment>
<sqlFile path="oracle/schemas/eldata/2016-08/2016-08-25-cna-01/20160825_01_upd-data-eldata-cis_case_kr.sql”/>
<property name="max.retry.count" value="100" />
</changeSet>
Error:
[ERROR] [system.err] Liquibase update Failed: Error parsing line 10730 column 50 of /opt/jenkins/workspace/EL-FT-DBV-LIQUIBASE-RETRY/Apps/Database/oracle/schemas/eldata/eldata-changelog.xml: cvc-complex-type.2.4.a: Invalid content was found starting with element 'property'. One of
'{"http://www.liquibase.org/xml/ns/dbchangelog":comment, "http://www.liquibase.org/xml/ns/dbchangelog":createTable, "http://www.liquibase.org/xml/ns/dbchangelog":dropTable, "http://www.liquibase.org/xml/ns/dbchangelog":createView, "http://www.liquibase.org/xml/ns/dbchangelog":renameView, "http://www.liquibase.org/xml/ns/dbchangelog":dropView, "http://www.liquibase.org/xml/ns/dbchangelog":insert, "http://www.liquibase.org/xml/ns/dbchangelog":addColumn, "http://www.liquibase.org/xml/ns/dbchangelog":sql, "http://www.liquibase.org/xml/ns/dbchangelog":createProcedure, "http://www.liquibase.org/xml/ns/dbchangelog":sqlFile, "http://www.liquibase.org/xml/ns/dbchangelog":renameTable, "http://www.liquibase.org/xml/ns/dbchangelog":renameColumn, "http://www.liquibase.org/xml/ns/dbchangelog":dropColumn, "http://www.liquibase.org/xml/ns/dbchangelog":mergeColumns, "http://www.liquibase.org/xml/ns/dbchangelog":modifyDataType, "http://www.liquibase.org/xml/ns/dbchangelog":createSequence, "http://www.liquibase.org/xml/ns/dbchangelog":alterSequence, "http://www.liquibase.org/xml/ns/dbchangelog":dropSequence, "http://www.liquibase.org/xml/ns/dbchangelog":createIndex, "http://www.liquibase.org/xml/ns/dbchangelog":dropIndex, "http://www.liquibase.org/xml/ns/dbchangelog":addNotNullConstraint, "http://www.liquibase.org/xml/ns/dbchangelog":dropNotNullConstraint, "http://www.liquibase.org/xml/ns/dbchangelog":addForeignKeyConstraint, "http://www.liquibase.org/xml/ns/dbchangelog":dropForeignKeyConstraint, "http://www.liquibase.org/xml/ns/dbchangelog":dropAllForeignKeyConstraints, "http://www.liquibase.org/xml/ns/dbchangelog":addPrimaryKey, "http://www.liquibase.org/xml/ns/dbchangelog":dropPrimaryKey, "http://www.liquibase.org/xml/ns/dbchangelog":addLookupTable, "http://www.liquibase.org/xml/ns/dbchangelog":addAutoIncrement, "http://www.liquibase.org/xml/ns/dbchangelog":addDefaultValue, "http://www.liquibase.org/xml/ns/dbchangelog":dropDefaultValue, "http://www.liquibase.org/xml/ns/dbchangelog":addUniqueConstraint, "http://www.liquibase.org/xml/ns/dbchangelog":dropUniqueConstraint, "http://www.liquibase.org/xml/ns/dbchangelog":customChange, "http://www.liquibase.org/xml/ns/dbchangelog":update, "http://www.liquibase.org/xml/ns/dbchangelog":delete, "http://www.liquibase.org/xml/ns/dbchangelog":loadData, "http://www.liquibase.org/xml/ns/dbchangelog":loadUpdateData, "http://www.liquibase.org/xml/ns/dbchangelog":executeCommand, "http://www.liquibase.org/xml/ns/dbchangelog":stop, "http://www.liquibase.org/xml/ns/dbchangelog":rollback, WC[##other:"http://www.liquibase.org/xml/ns/dbchangelog"], "http://www.liquibase.org/xml/ns/dbchangelog":modifySql}' is expected.
So that seems to be the list of property name’s I can use
Therefore it seems liqubibase does not have any “RETRY” property.
seems SQL itself provides looping based on the error code being received:
BEGIN
FOR i IN 1..5 LOOP -- Try transaction at most 5 times.
DBMS_OUTPUT.PUT('Try #' || i);
BEGIN -- sub-block begins
SAVEPOINT start_transaction;
-- transaction begins
DELETE FROM results WHERE res_answer = 'NO';
INSERT INTO results (res_name, res_answer) VALUES (name, answer);
-- Nonunique name raises DUP_VAL_ON_INDEX.
-- If transaction succeeded:
COMMIT;
DBMS_OUTPUT.PUT_LINE(' succeeded.');
EXIT;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
DBMS_OUTPUT.PUT_LINE(' failed; trying again.');
ROLLBACK TO start_transaction; -- Undo changes.
suffix := suffix + 1; -- Try to fix problem.
name := name || TO_CHAR(suffix);
END; -- sub-block ends
END LOOP;
END;
Is that the only way, i can provide retry in liquibase for SQL ? if so, then, is there a way i can use a variable in place of 5 , in the 1..5 loop ?

triggers in sql files with oracle 11g database don't work

I have a problem with Oracle 11g and Liquibase. I been looking for an good answer everywere. In my db-changelog.xml I point to a sql file where I have triggers. This does not work at all. I have tested the things you said above with /\; and one and several triggers. I get an ORA-00911 with /. Ora-00900 with END "name of the trigger"; in the sql.
CREATE OR REPLACE TRIGGER ADRESSE_ID_TR
BEFORE INSERT ON ADRESSE
FOR EACH ROW
WHEN (new.ID IS NULL) BEGIN
SELECT adresse_seq.NEXTVAL
INTO :new.ID
FROM dual;
END ADRESSE_ID_TR;\
My workaround is adding a in in db-changelog.xml. I don't like it because the db-changelog.xml is going to be very large and I want it in the .sql files not in db-changelog.xml. When we develop java code we are going to have a lot changes to the database. The changes should be in bigger sql files. Or am I wrong here?
Another problem is when I generate DDL's with tools like Oracle SQL Developer, Toad,SQL Plus etc. they don't work. The DDL's works when I execute them with the tools. A lot of sql's don't work because SQL's are probably not supported in Liquibase. I spend a lot of time testing my SQL's and Liquibase with Eclipse to fix the SQL's. Any tips or will you fix this?
I do get errors due to changes to trigger code:
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
My sql is like this:
--liquibase formatted 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;
My db-changelog.xml: (The triggers in .xml file works fine those I put in .sql don't work)
<?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>
That's not valid trigger syntax; what's below is:
CREATE OR REPLACE TRIGGER ADRESSE_ID_TR
BEFORE INSERT ON ADRESSE
FOR EACH ROW
BEGIN
IF (:new.ID IS NULL) THEN
SELECT adresse_seq.NEXTVAL
INTO :new.ID
FROM dual;
END IF;
END ADRESSE_ID_TR;
/