-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrigger-Test.sql
More file actions
71 lines (62 loc) · 1.83 KB
/
Copy pathTrigger-Test.sql
File metadata and controls
71 lines (62 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
drop table trigger_test_tab;
drop sequence trigger_test_seq;
create sequence trigger_test_seq;
create table trigger_test_tab
(id number constraint trigger_test_tab_nn1 not null
,name varchar2(30) constraint trigger_test_tab_nn2 not null
,created_dtm date constraint trigger_test_tab_nn3 not null
,constraint trigger_test_tab_pk primary key (id)
,constraint trigger_test_tab_uk1 unique (name)
);
create or replace trigger trigger_test_bir
before insert on trigger_test_tab
for each row
begin
if :new.id is null
then
:new.id := trigger_test_seq.nextval;
end if;
:new.created_dtm := sysdate;
end;
/
create or replace package trigger_test_pkg authid definer
as
procedure wtplsql_run;
end trigger_test_pkg;
/
create or replace package body trigger_test_pkg
as
procedure t_happy_path_1
is
l_rec trigger_test_tab%ROWTYPE;
begin
wt_assert.g_testcase := 'Constructor Happy Path 1';
insert into trigger_test_tab (name) values ('Test1')
returning id into l_rec.id;
wt_assert.isnotnull (
msg_in => 'l_rec.id',
check_this_in => l_rec.id);
select * into l_rec from trigger_test_tab where id = l_rec.id;
wt_assert.eq (
msg_in => 'l_rec.name',
check_this_in => l_rec.name,
against_this_in => 'Test1');
wt_assert.isnotnull (
msg_in => 'l_rec.created_dtm',
check_this_in => l_rec.created_dtm);
rollback;
end t_happy_path_1;
--% WTPLSQL SET DBOUT "TRIGGER_TEST_BIR:TRIGGER" %--
procedure wtplsql_run
is
begin
t_happy_path_1;
end wtplsql_run;
end trigger_test_pkg;
/
set serveroutput on size unlimited format word_wrapped
begin
wtplsql.test_run('TRIGGER_TEST_PKG');
wt_text_report.dbms_out(USER,'TRIGGER_TEST_PKG',30);
end;
/