-
Notifications
You must be signed in to change notification settings - Fork 24
/
run.sql
69 lines (51 loc) · 1.73 KB
/
run.sql
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
create or replace package polymorphic_intro as
function describe (tab in out dbms_tf.table_t)
return dbms_tf.describe_t;
--
-- Note: There is only a specification for this function, but
-- no implementation.
--
function pass_table_on(tab in table)
return table
pipelined row polymorphic
using polymorphic_intro;
end polymorphic_intro;
/
create or replace package body polymorphic_intro AS
function describe (tab in out DBMS_TF.table_t)
return dbms_tf.describe_t as
begin
dbms_output.put_line('poly_pkg.describe was called.');
return null;
end describe;
end polymorphic_intro;
/
show errors
create table table_ptf (
num integer,
txt varchar2(10)
);
create table table_ptf_same_structure (
num integer,
txt varchar2(10)
);
create table table_ptf_different_structure (
txt varchar2(10),
num integer
);
insert into table_ptf values (1, 'one' );
insert into table_ptf values (2, 'two' );
insert into table_ptf values (3, 'three');
insert into table_ptf_same_structure values (4, 'four');
insert into table_ptf_same_structure values (5, 'five');
insert into table_ptf_different_structure values ('six' , 6);
insert into table_ptf_different_structure values ('seven', 8);
commit;
select * from polymorphic_intro.pass_table_on(table_ptf);
select * from polymorphic_intro.pass_table_on(table_ptf_same_structure);
select * from polymorphic_intro.pass_table_on(table_ptf_different_structure);
select * from polymorphic_intro.pass_table_on(table_ptf);
drop package polymorphic_intro;
drop table table_ptf purge;
drop table table_ptf_same_structure purge;
drop table table_ptf_different_structure purge;