DBA Data[Home] [Help]

TYPE BODY: SYS.V_LBRECSETIMPL_T

Source


1 type body v_lbRecSetImpl_t is
2 
3   static function ODCITablePrepare(sctx OUT v_lbRecSetImpl_t,
4                                    ti   IN  SYS.ODCITabFuncInfo)
5     return number is
6   begin
7     -- create instance of object, initialise curval, done and needobsolete
8     sctx:=v_lbRecSetImpl_t(0, 0, 0);
9 
10     -- check if user is interested in obsolete column. If this column location
11     -- is changed in object definition, this should be fixed.
12     for i in ti.Attrs.first .. ti.Attrs.last
13     loop
14       if (ti.Attrs(i) = 20) then
15          sctx.needobsolete := 1;
16          exit;
17       end if;
18     end loop;
19 
20     return SYS.ODCIConst.Success;
21   end ODCITablePrepare;
22 
23   static function ODCITableStart(sctx IN OUT v_lbRecSetImpl_t)
24     return number is
25   begin
26     return SYS.ODCIConst.Success;
27   end ODCITableStart;
28 
29 -- Fetch function is not called more than once. It returns all rows when
30 -- called first time for each query because we can not have package composite
31 -- types within object definition. For the same reason, the nrows parameter
32 -- is ignored.
33   member function ODCITableFetch(self   IN OUT v_lbRecSetImpl_t,
34                                  nrows  IN     number,
35                                  objSet OUT    v_lbRecSet_t)
36     return number is
37     n               number  := 0;
38     firstCall       boolean := TRUE;
39     ret             boolean := TRUE;
40     redundancy      number;
41     recovery_window number;
42     untilTime       date;
43     lbRec           sys.dbms_rcvman.lbrec_t;
44     lbCursor        sys.dbms_rcvman.lbCursor_t;
45     lbState         sys.dbms_rcvman.lbState_t;
46   begin
47     objSet:=v_lbRecSet_t();
48 
49     -- reset package state
50     sys.dbms_rcvman.resetAll;
51     -- Set database so that user does not need to care
52     sys.dbms_rcvman.setDatabase(NULL, NULL, NULL, NULL);
53 
54     redundancy := 1;
55     recovery_window := 0;
56 
57     -- We need to get the retention policy, and to set untilTime if
58     -- retention policy is recovery_window.
59     -- Get retention policy (recovery window and redunadcy).
60     sys.dbms_rcvman.getRetentionPolicy(recovery_window, redundancy);
61 
62     -- Always work with all incarnations.
63     sys.dbms_rcvman.setAllIncarnations(TRUE);
64 
65     -- Set untilTime and untilSCN for recovery window (if any).
66     if (recovery_window > 0)
67     then
68       select (sysdate-recovery_window) into untilTime from dual;
69       sys.dbms_rcvman.setUntilTime(untilTime);
70     end if;
71 
72     sys.dbms_rcvman.setDeviceTypeAny;
73 
74     if (recovery_window = 0 and redundancy = 0) then
75        -- don't need obsolete data if there the policy is NONE
76        sys.dbms_rcvman.setNeedObsoleteData(false);
77     else
78        if self.needobsolete = 1 then
79           sys.dbms_rcvman.setNeedObsoleteData(true);
80        else
81           sys.dbms_rcvman.setNeedObsoleteData(false);
82        end if;
83     end if;
84 
85     while ret and self.done = 0 loop
86       ret := sys.dbms_rcvman.listBackup(lbRec, firstCall, FALSE,
87                                         redundancy,
88                                         TRUE, lbCursor, lbState, null);
89       if (lbRec.pkey is not null)
90       then
91         objSet.extend;
92         n := n + 1;
93         objSet(n):= v_lbRec_t(
94                             to_number(null),   -- list_order1
95                             to_number(null),   -- list_order2
96                             to_number(null),   -- pkey
97                             to_char(null),     -- backup_type
98                             to_char(null),     -- file_type
99                             to_char(null),     -- keep
100                             to_date(null),     -- keep_until
101                             to_char(null),     -- keep_options
102                             to_char(null),     -- status
103                             to_char(null),     -- fname
104                             to_char(null),     -- tag
105                             to_char(null),     -- media
106                             to_number(null),   -- recid
107                             to_number(null),   -- stamp
108                             to_char(null),     -- device_type
109                             to_number(null),   -- block_size
110                             to_date(null),     -- completion_time
111                             to_char(null),     -- is_rdf
112                             to_char(null),     -- compressed
113                             to_char(null),     -- obsolete
114                             to_number(null),   -- bytes
115                             to_number(null),   -- bs_key
116                             to_number(null),   -- bs_count
117                             to_number(null),   -- bs_stamp
118                             to_char(null),     -- bs_type
119                             to_char(null),     -- bs_incr_type
120                             to_number(null),   -- bs_pieces
121                             to_number(null),   -- bs_copies
122                             to_date(null),     -- bs_completion_time
123                             to_char(null),     -- bs_status
124                             to_number(null),   -- bs_bytes
125                             to_char(null),     -- bs_compressed
126                             to_char(null),     -- bs_tag
127                             to_char(null),     -- bs_device_type
128                             to_number(null),   -- bp_piece#
129                             to_number(null),   -- bp_copy#
130                             to_number(null),   -- df_file#
131                             to_number(null),   -- df_ts#
132                             to_number(null),   -- df_plugin_change#
133                             to_number(null),   -- df_foreign_dbid
134                             to_char(null),     -- df_tablespace
135                             to_number(null),   -- df_resetlogs_change#
136                             to_number(null),   -- df_creation_change#
137                             to_number(null),   -- df_checkpoint_change#
138                             to_date(null),     -- df_ckp_mod_time
139                             to_number(null),   -- df_incremental_change#
140                             to_number(null),   -- rl_thread#
141                             to_number(null),   -- rl_sequence#
142                             to_number(null),   -- rl_resetlogs_change#
143                             to_number(null),   -- rl_first_change#
144                             to_date(null),     -- rl_first_time
145                             to_number(null),   -- rl_next_change#
146                             to_date(null),     -- rl_next_time
147                             to_number(null));  -- con_id
148         objSet(n).list_order1            := lbRec.list_order1;
149         objSet(n).list_order2            := lbRec.list_order2;
150         objSet(n).pkey                   := lbRec.pkey;
151         objSet(n).backup_type            := lbRec.backup_type;
152         objSet(n).file_type              := lbRec.file_type;
153         objSet(n).keep                   := lbRec.keep;
154         objSet(n).keep_until             := lbRec.keep_until;
155         objSet(n).keep_options           := lbRec.keep_options;
156         objSet(n).status                 := lbRec.status;
157         objSet(n).fname                  := lbRec.fname;
158         objSet(n).tag                    := lbRec.tag;
159         objSet(n).media                  := lbRec.media;
160         objSet(n).recid                  := lbRec.stamp;
161         objSet(n).stamp                  := lbRec.stamp;
162         objSet(n).device_type            := lbRec.device_type;
163         objSet(n).block_size             := lbRec.block_size;
164         objSet(n).completion_time        := lbRec.completion_time;
165         objSet(n).is_rdf                 := lbRec.is_rdf;
166         objSet(n).compressed             := lbRec.compressed;
167         objSet(n).obsolete               := lbRec.obsolete;
168         objSet(n).bytes                  := lbRec.bytes;
169         objSet(n).bs_key                 := lbRec.bs_key;
170         objSet(n).bs_count               := lbRec.bs_count;
171         objSet(n).bs_stamp               := lbRec.bs_stamp;
172         objSet(n).bs_type                := lbRec.bs_type;
173         objSet(n).bs_incr_type           := lbRec.bs_incr_type;
174         objSet(n).bs_pieces              := lbRec.bs_pieces;
175         objSet(n).bs_copies              := lbRec.bs_copies;
176         objSet(n).bs_completion_time     := lbRec.bs_completion_time;
177         objSet(n).bs_status              := lbRec.bs_status;
178         objSet(n).bs_bytes               := lbRec.bs_bytes;
179         objSet(n).bs_compressed          := lbRec.bs_compressed;
180         objSet(n).bs_tag                 := lbRec.bs_tag;
181         objSet(n).bs_device_type         := lbRec.bs_device_type;
182         objSet(n).bp_piece#              := lbRec.bp_piece#;
183         objSet(n).bp_copy#               := lbRec.bp_copy#;
184         objSet(n).df_file#               := lbRec.df_file#;
185         objSet(n).df_ts#                 := lbRec.df_ts#;
186         objSet(n).df_plugin_change#      := lbRec.df_plugin_change#;
187         objSet(n).df_foreign_dbid        := lbRec.df_foreign_dbid;
188         objSet(n).df_tablespace          := lbRec.df_tablespace;
189         objSet(n).df_resetlogs_change#   := lbRec.df_resetlogs_change#;
190         objSet(n).df_creation_change#    := lbRec.df_creation_change#;
191         objSet(n).df_checkpoint_change#  := lbRec.df_checkpoint_change#;
192         objSet(n).df_ckp_mod_time        := lbRec.df_ckp_mod_time;
193         objSet(n).df_incremental_change# := lbRec.df_incremental_change#;
194         objSet(n).rl_thread#             := lbRec.rl_thread#;
195         objSet(n).rl_sequence#           := lbRec.rl_sequence#;
196         objSet(n).rl_resetlogs_change#   := lbRec.rl_resetlogs_change#;
197         objSet(n).rl_first_change#       := lbRec.rl_first_change#;
198         objSet(n).rl_first_time          := lbRec.rl_first_time;
199         objSet(n).rl_next_change#        := lbRec.rl_next_change#;
200         objSet(n).rl_next_time           := lbRec.rl_next_time;
201         objSet(n).con_id                 := lbRec.con_id;
202       end if;
203       firstCall := false;
204       self.curval:=self.curval+1;
205       if not ret then
206         self.done := 1;
207       end if;
208     end loop;
209     return SYS.ODCIConst.Success;
210   end ODCITableFetch;
211 
212   member function ODCITableClose(self IN v_lbRecSetImpl_t)
213     return number
214   is
215   begin
216     return SYS.ODCIConst.Success;
217   end ODCITableClose;
218 end;