DBA Data[Home] [Help]

PACKAGE: SYS.DBMS_METADATA_UTIL

Source


1 PACKAGE dbms_metadata_util AUTHID DEFINER AS
2 ------------------------------------------------------------
3 -- Overview
4 -- This pkg implements utility functions of the mdAPI.
5 ---------------------------------------------------------------------
6 -- SECURITY
7 -- This package is owned by SYS. It runs with definers, not invokers rights
8 -- because it needs to access dictionary tables.
9 
10 -------------
11 -- EXCEPTIONS
12 --
13   invalid_argval EXCEPTION;
14     PRAGMA EXCEPTION_INIT(invalid_argval, -31600);
15     invalid_argval_num NUMBER := -31600;
16 -- "Invalid input value %s for parameter %s in function %s"
17 -- *Cause:  A NULL or invalid value was supplied for the parameter.
18 -- *Action: Correct the input value and try the call again.
19 
20   invalid_operation EXCEPTION;
21     PRAGMA EXCEPTION_INIT(invalid_operation, -31601);
22     invalid_operation_num NUMBER := -31601;
23 -- "Function %s cannot be called now that fetch has begun"
24 -- *Cause:  The function was called after the first call to FETCH_xxx.
25 -- *Action: Correct the program.
26 
27   inconsistent_args EXCEPTION;
28     PRAGMA EXCEPTION_INIT(inconsistent_args, -31602);
29     inconsistent_args_num NUMBER := -31602;
30 -- "parameter %s value \"%s\" in function %s inconsistent with %s"
31 -- "Value \"%s\" for parameter %s in function %s is inconsistent with %s"
32 -- *Cause:  The parameter value is inconsistent with another value specified
33 --          by the program.  It may be not valid for the the object type
34 --          associated with the OPEN context, or it may be of the wrong
35 --          datatype: a boolean rather than a text string or vice versa.
36 -- *Action: Correct the program.
37 
38   object_not_found EXCEPTION;
39     PRAGMA EXCEPTION_INIT(object_not_found, -31603);
40     object_not_found_num NUMBER := -31603;
41 -- "object \"%s\" of type %s not found in schema \"%s\""
42 -- *Cause:  The specified object was not found in the database.
43 -- *Action: Correct the object specification and try the call again.
44 
45   invalid_object_param EXCEPTION;
46     PRAGMA EXCEPTION_INIT(invalid_object_param, -31604);
47     invalid_object_param_num NUMBER := -31604;
48 -- "invalid %s parameter \"%s\" for object type %s in function %s"
49 -- *Cause:  The specified parameter value is not valid for this object type.
50 -- *Action: Correct the parameter and try the call again.
51 
52   inconsistent_operation EXCEPTION;
53     PRAGMA EXCEPTION_INIT(inconsistent_operation, -31607);
54     inconsistent_operation_num NUMBER := -31607;
55 -- "Function %s is inconsistent with transform."
56 -- *Cause:  Either (1) FETCH_XML was called when the "DDL" transform
57 --          was specified, or (2) FETCH_DDL was called when the
58 --          "DDL" transform was omitted.
59 -- *Action: Correct the program.
60 
61   object_not_found2 EXCEPTION;
62     PRAGMA EXCEPTION_INIT(object_not_found2, -31608);
63     object_not_found2_num NUMBER := -31608;
64 -- "specified object of type %s not found"
65 -- (Used by GET_DEPENDENT_xxx and GET_GRANTED_xxx.)
66 -- *Cause:  The specified object was not found in the database.
67 -- *Action: Correct the object specification and try the call again.
68 
69   stylesheet_load_error EXCEPTION;
70     PRAGMA EXCEPTION_INIT(stylesheet_load_error, -31609);
71     stylesheet_load_error_num NUMBER := -31609;
72 -- "error loading file %s from file system directory \'%s\'"
73 -- *Cause:  The installation script initmeta.sql failed to load
74 --          the named file from the file system directory into the database.
75 -- *Action: Examine the directory and see if the file is present
76 --          and can be read.
77 
78   procobj_error EXCEPTION;
79     PRAGMA EXCEPTION_INIT(procobj_error, -39127);
80     procobj_error_num NUMBER := -39127;
81 -- "Unexpected error from call to %s \n%s"
82 -- *Cause:  The exception was raised by the function invocation.
83 -- *Action: Record the accompanying messages and report this as a Data Pump
84 --          internal error to customer support.
85 
86   bad_hashcode EXCEPTION;
87     PRAGMA EXCEPTION_INIT(bad_hashcode, -39132);
88     bad_hashcode_num NUMBER := -39132;
89 -- "Object type \"%s\".\"%s\" already exists with different hashcode"
90 -- *Cause:  An object type cannot be created because it already exists on the
91 --          target system, but with a different hashcode.  Tables in the
92 --          transportable tablespace set which use this object type
93 --          cannot be read.
94 -- *Action: Drop the object type from the target system and retry the
95 --          operation.
96 
97   type_in_use EXCEPTION;
98     PRAGMA EXCEPTION_INIT(type_in_use, -39133);
99     type_in_use_num NUMBER := -39133;
100 -- "Object type \"%s\".\"%s\" already exists with different typeid"
101 -- *Cause:  An object type in a transportable tablespace set already exists
102 --          on the target system, but with a different typeid.  The typeid
103 --          cannot be changed because the type is used by an existing table.
104 --          Tables in the transportable tablespace set which use this object
105 --          type cannot be read.
106 -- *Action: Drop the object type from the target system and retry the
107 --          operation.
108 
109 ---------------------------
110 
111 -- PACKAGE VARIABLES
112 
113   marker NUMBER := 42;  -- marker number: used in worker/mcp to take actions
114                         -- at appropriate times, without depending on
115                         -- pathnames
116 
117 ---------------------------
118 
119 -- PROCEDURES AND FUNCTIONS
120 --
121 -- PUT_LINE: Does a DBMS_OUTPUT.PUT_LINE regardless of string length; i.e,
122 --              works with strings > 255.
123 
124   PROCEDURE put_line(stmt IN VARCHAR2);
125 
126 -- PUT_BOOL: Convenience function.
127 
128   PROCEDURE put_bool(
129         stmt    IN VARCHAR2,
130         value   IN BOOLEAN);
131 
132 
133 -- VSN2NUM: Convert a dot-separated version string (e.g., '8.1.6.0.0')
134 --   to a number (e.g., 8010600000).
135 
136   FUNCTION vsn2num (
137                 vsn             IN  VARCHAR2)
138         RETURN NUMBER;
139 
140 -- GET_COMPAT_VSN: return the compatibility version number as a number.
141 --       E.g., if compatibility='8.1.6', return 801060000.
142 
143   FUNCTION get_compat_vsn
144         RETURN NUMBER;
145 
146 -- GET_ATTRNAME: attrname for a table-column.
147 
148   FUNCTION get_attrname ( obj    IN NUMBER,
149                               intcol IN NUMBER)
150         RETURN VARCHAR2;
151 
152 -- GET_FULLATTRNAME: return fully qualified attrname, when attrname is a
153 --                     system generated name.
154 
155   FUNCTION get_fullattrname ( obj    IN NUMBER,
156                               col    IN NUMBER,
157                               intcol IN NUMBER,
158                               type   IN NUMBER)
159         RETURN VARCHAR2;
160 
161 -- GET_DB_VSN: return the database version number as a string
162 --       in the format vv.vv.vv.vv.vv, e.g., '08.01.03.00.00'
163 
164   FUNCTION get_db_vsn
165         RETURN VARCHAR2;
166 
167 -- GET_CANONICAL_VSN: convert the user's VERSION param to a string
168 --       in the format vv.vv.vv.vv.vv, e.g., '08.01.03.00.00'
169 -- PARAMETERS:
170 --      version         - The version from DBMS_METADATA.OPEN.
171 --              Values can be 'COMPATIBLE' (default), 'LATEST' or a specific
172 --              version number.
173 
174   FUNCTION get_canonical_vsn(version IN VARCHAR2)
175         RETURN VARCHAR2;
176 
177 ---------------------------------------------------------------------
178 -- CONVERT_TO_CANONICAL: Convert string to canonical form
179 --       vv.vv.vv.vv.vv, e.g., '08.01.03.00.00'
180 -- PARAMETERS:
181 --      version         - version string (e.g., 10.2.0.2)
182 
183   FUNCTION convert_to_canonical(version IN VARCHAR2)
184         RETURN VARCHAR2;
185 
186 
187 -- GET_LATEST_VSN: return a number that will serve as the latest version number
188 
189   FUNCTION get_latest_vsn
190         RETURN NUMBER;
191 
192 
193 -- GET_OPEN_MODE: return a number signifying the open mode of the database
194 -- RETURNS:     0 = MOUNTED
195 --              1 = READ WRITE
196 --              2 = READ ONLY
197 
198   FUNCTION get_open_mode
199         RETURN NUMBER;
200 
201 -- LONG2VARCHAR: Convert a LONG column value to a VARCHAR2
202 -- PARAMETERS:
203 --      length          - length of the LONG
204 --      tab             - table name
205 --      col             - column name
206 --      row             - rowid of the row
207 -- RETURNS:     LONG value converted to VARCHAR2 if length <= 4000
208 --              otherwise NULL
209 
210   FUNCTION long2varchar(
211                 length          IN  NUMBER,
212                 tab             IN  VARCHAR2,
213                 col             IN  VARCHAR2,
214                 row             IN  UROWID)
215         RETURN VARCHAR2;
216 
217 -- LONG2VCMAX: Convert a LONG column value to a VARCHAR2 and each line
218 --                  max length is 2000
219 -- PARAMETERS:
220 --      length          - length of the LONG
221 --      tab             - table name
222 --      col             - column name
223 --      row             - rowid of the row
224 -- RETURNS:     LONG value converted to VARCHAR2
225 --              otherwise NULL
226 
227 
228   FUNCTION long2vcmax(
229                 length          IN  NUMBER,
230                 tab             IN  VARCHAR2,
231                 col             IN  VARCHAR2,
232                 row             IN  UROWID)
233         RETURN sys.ku$_vcnt;
234 
235 -- LONG2VCNT: Convert a LONG column value to an array of VARCHAR2
236 -- PARAMETERS:
237 --      length          - length of the LONG
238 --      tab             - table name
239 --      col             - column name
240 --      row             - rowid of the row
241 -- RETURNS:     LONG value converted to array of VARCHAR2 if length > 4000
242 --              otherwise NULL
243 
244   FUNCTION long2vcnt(
245                 length          IN  NUMBER,
246                 tab             IN  VARCHAR2,
247                 col             IN  VARCHAR2,
248                 row             IN  UROWID)
249         RETURN sys.ku$_vcnt;
250 
251 -- LONG2CLOB: Convert a LONG column value to a CLOB
252 -- PARAMETERS:
253 --      length          - length of the LONG
254 --      tab             - table name
255 --      col             - column name
256 --      row             - rowid of the row
257 -- RETURNS:     LONG value converted to temporary CLOB if length > 4000
258 --              otherwise NULL
259 
260   FUNCTION long2clob(
261                 length          IN  NUMBER,
262                 tab             IN  VARCHAR2,
263                 col             IN  VARCHAR2,
264                 row             IN  ROWID)
265         RETURN CLOB;
266 
267 -- PARSE_CONDITION: Parse a check constraint condition on a table
268 --   and return it as XML
269 -- PARAMETERS:
270 --      schema          - schema
271 --      tab             - table name
272 --      length          - length of the constraint
273 --      row             - rowid of the row in CDEF$
274 -- RETURNS:     XMLType containing parsed condition as XML
275 --                 if length is not NULL
276 --              otherwise NULL
277 
278   FUNCTION parse_condition(
279                 schema          IN  VARCHAR2,
280                 tab             IN  VARCHAR2,
281                 length          IN  NUMBER,
282                 row             IN  ROWID)
283         RETURN SYS.XMLTYPE;
284 
285 -- PARSE_DEFAULT: Parse the default value of a virtual column
286 --   (which contains an arithmetic expression for a functional index)
287 --   and return it as XML
288 -- PARAMETERS:
289 --      schema          - schema
290 --      tab             - table name
291 --      length          - length of the default
292 --      row             - rowid of the row in COL$
293 -- RETURNS:     XMLType containing parsed expression as XML
294 --                 if length is not NULL
295 --              otherwise NULL
296 
297   FUNCTION parse_default(
298                 schema          IN  VARCHAR2,
299                 tab             IN  VARCHAR2,
300                 length          IN  NUMBER,
301                 row             IN  ROWID)
302         RETURN SYS.XMLTYPE;
303 
304 -- PARSE_QUERY: Parse a query stored in a long column (e.g., view query).
305 --   and return it as XML
306 -- PARAMETERS:
307 --      schema          - schema
308 --      length          - length of the LONG
309 --      tab             - table name
310 --      col             - column name
311 --      row             - rowid of the row
312 --      read_only       - non-0 = query has 'with read only'
313 --      check_option    - non-0 = query has 'with check option'
314 -- RETURNS:     XMLType containing parsed query as XML
315 --                 if length is not NULL
316 --              otherwise NULL
317 
318   FUNCTION parse_query(
319                 schema          IN  VARCHAR2,
320                 length          IN  NUMBER,
321                 tab             IN  VARCHAR2,
322                 col             IN  VARCHAR2,
323                 row             IN  ROWID,
324                 read_only       IN  NUMBER DEFAULT 0,
325                 check_option    IN  NUMBER DEFAULT 0)
326         RETURN SYS.XMLTYPE;
327 
328 -- PARSE_QUERY: Parse a query stored in a clob
329 --   and return it as XML
330 -- PARAMETERS:
331 --      schema          - schema
332 --      query           - query text
333 --      read_only       - non-0 = query has 'with read only'
334 --      check_option    - non-0 = query has 'with check option'
335 -- RETURNS:     XMLType containing parsed query as XML
336 --                 if length is not NULL
337 --              otherwise NULL
338 
339   FUNCTION parse_query(
340                 schema          IN  VARCHAR2,
341                 query           IN  CLOB,
342                 read_only       IN  NUMBER DEFAULT 0,
343                 check_option    IN  NUMBER DEFAULT 0)
344         RETURN SYS.XMLTYPE;
345 
346 -- NULLTOCHR0 - Replace \0 with CHR(0) in varchar
347 -- PARAMETERS:
348 --      value           - varchar value
349 --      replace_quote   - TRUE = replace ' with ''
350 -- RETURNS: varchar value with substitutions made
351 
352   FUNCTION nulltochr0(
353                 value           IN  VARCHAR2,
354                 replace_quote   IN  BOOLEAN DEFAULT TRUE)
355         RETURN VARCHAR2;
356 
357 -- GET_SOURCE_LINES: Get records from source$ for the object
358 -- and annotate them to make xsl processing easier.
359 -- PARAMETERS:
360 --      obj_name        - name of object
361 --      obj_num         - obj# of object
362 --      type_num        - type# of object
363 -- RETURNS:     Nested table containing the source lines
364 
365   FUNCTION get_source_lines(
366                 obj_name        IN  VARCHAR2,
367                 obj_num         IN  NUMBER,
368                 type_num        IN  NUMBER)
369         RETURN sys.ku$_source_list_t;
370 
371 -- PARSE_TRIGGER_DEFINITION: Return "annotated" trigger definition
372 --  to make xsl processing easier.
373 -- PARAMETERS:
374 --      owner           - owner name
375 --      obj_name        - trigger name
376 --      definition      - the definition from trigger$
377 -- RETURNS:     The annotated definition
378 
379   FUNCTION  parse_trigger_definition(
380                 owner           IN  VARCHAR2,
381                 obj_name        IN  VARCHAR2,
382                 definition      IN  VARCHAR2)
383         RETURN sys.ku$_source_t;
384 
385 -- SAVE_PROCOBJ_ERRORS: Construct a text string for a raised exception
386 -- and store it in the package variable 'procobj_errors'.
387 
388   PROCEDURE save_procobj_errors(
389                 sql_stmt        IN  VARCHAR2 );
390 
391 -- GET_PROCOBJ_ERRORS: Retrieve saved errors and reset state.
392 -- PARAMETERS:
393 --              err_list        - the saved errors
394 -- RETURN VALUE:
395 --              error count
396 
397   PROCEDURE get_procobj_errors(
398                 err_list        OUT sys.ku$_vcnt);
399 
400 -- GET_AUDIT: Return audit information for a schema object.
401 -- PARAMETERS:
402 --      obj_num         - object number
403 --      type_num        - object type
404 -- RETURNS: nested table of audit settings
405 
406  FUNCTION get_audit(
407                 obj_num         IN  NUMBER,
408                 type_num        IN  NUMBER )
409         RETURN sys.ku$_audit_list_t;
410 
411 -- GET_AUDIT_DEFAULT: Return default object audit information setting.
412 -- PARAMETERS:
413 --      obj_num         - object number
414 -- RETURNS: nested table of default audit settings
415 
416  FUNCTION get_audit_default(
417                 obj_num         IN  NUMBER)
418         RETURN sys.ku$_audit_default_list_t;
419 
420 
421 -- GET_ANC: Get the object number of the base table to which
422 --      a nested table belongs
423 -- PARAMETERS:
427 --                        2 - include only NTs for XMLtype OR storage
424 --      nt              - obj# of the nested table
425 --      exclude_xml     - 0 - return anc for all NTs
426 --                        1 - exclude NTs for XMLtype OR storage
428 -- RETURNS:
429 --      obj# of the base table
430 
431  FUNCTION get_anc(
432                 nt              IN NUMBER,
433                 exclude_xml     IN NUMBER := 1)
434         RETURN NUMBER;
435 
436 
437 -- GET_ENDIANNESS: function to determine endianness:
438 -- RETURNS:
439 --      1 = big_endian
440 --      2 = little_endian
441 
442  FUNCTION get_endianness
443         RETURN NUMBER;
444 
445 -- SET_VERS_DPAPI: Save Direct Path API version.
446 -- PARAMETERS:
447 --      version         - version number
448 
449  PROCEDURE set_vers_dpapi (
450                 version         IN  NUMBER);
451 
452 -- GET_VERS_DPAPI: Retrieve saved Direct Path API version.
453 -- RETURNS: version number
454 
455  FUNCTION get_vers_dpapi
456         RETURN NUMBER;
457 
458 -- SET_FORCE_LOB_BE: Save the 'force_lob_be' switch.
459 -- PARAMETERS:
460 --      value          - switch value
461 
462  PROCEDURE set_force_lob_be (
463                 value           IN  BOOLEAN);
464 
465 -- SET_FORCE_NO_ENCRYPT: Save the 'force_no_encrypt' switch.
466 -- PARAMETERS:
467 --      value          - switch value
468 
469  PROCEDURE set_force_no_encrypt (
470                 value           IN  BOOLEAN);
471 
472 
473 -- GET_LOB_PROPERTY: Return lob$.property (but clear bit 0x0200 if
474 --    force_lob_be is set; 0x0200 = LOB data in little endian format).
475 -- PARAMETERS:
476 --      objnum         - obj# of table
477 --      intcol_num     - intcol# of column
478 -- RETURNS: lob$.property, maybe with bit 0x0200 cleared
479 
480  FUNCTION get_lob_property (
481                 objnum          IN  NUMBER,
482                 intcol_num      IN  NUMBER)
483         RETURN NUMBER;
484 
485 -- GET_COL_PROPERTY: Return col$.property (but clear encryption bits if
486 --    force_no_encrypt flag is set:
487 --           0x04000000 =  67108864 = Column is encrypted
488 --           0x20000000 = 536870912 = Column is encrypted without salt
489 --           This is necessary when users do not specify an
490 --           encryption_password and the data is written to the dumpfile
491 --           in clear text although the col properity retains the
492 --           encrypt property.
493 -- PARAMETERS:
494 --      objnum         - obj# of table
495 --      intcol_num     - intcol# of column
496 -- RETURNS: col$.property, maybe with encryption bits cleared
497  FUNCTION get_col_property (
498                 objnum          IN  NUMBER,
499                 intcol_num      IN  NUMBER)
500         RETURN NUMBER;
501 
502 ---------------------------------------------------------------------
503 -- GET_REFRESH_MAKE_USER: Return refresh group dbms_refresh.make execute string
504 -- PARAMETERS:
505 --      group_id        - refresh group id
506 -- RETURNS: executing string
507 
508  FUNCTION get_refresh_make_user (
509                 group_id        IN  NUMBER)
510         RETURN varchar2;
511 
512 ---------------------------------------------------------------------
513 -- GET_REFRESH_ADD_USER: Return refresh group dbms_refresh.add execute string
514 -- PARAMETERS:
515 --      owner   - snapshot owner
516 --      child   - snapshot name
517 --      type    - type name
518 --      instsite - site id
519 -- RETURNS: executing string
520   FUNCTION get_refresh_add_user (
521                 owner           IN  VARCHAR2,
522                 child           IN  VARCHAR2,
523                 type            IN  VARCHAR2,
524                 instsite        IN VARCHAR2
525                 )
526         RETURN varchar2;
527 
528 ---------------------------------------------------------------------
529 -- GET_REFRESH_MAKE_DBA: Return refresh group dbms_irefresh.make execute string
530 -- PARAMETERS:
531 --      group_id        - refresh group id
532 -- RETURNS: executing string
533 
534  FUNCTION get_refresh_make_dba (
535                 group_id        IN  NUMBER)
536         RETURN varchar2;
537 
538 ---------------------------------------------------------------------
539 -- GET_REFRESH_ADD_DBA: Return refresh group dbms_irefresh.add execute string
540 -- PARAMETERS:
541 --      owner   - snapshot owner
542 --      child   - snapshot name
543 --      type    - type name
544 --      instsite - site id
545 -- RETURNS: executing string
546   FUNCTION get_refresh_add_dba (
547                 owner           IN  VARCHAR2,
548                 child           IN  VARCHAR2,
549                 type            IN  VARCHAR2,
550                 instsite        IN VARCHAR2
551                 )
552         RETURN varchar2;
553 
554 ---------------------------------------------------------------------
555 -- LOAD_STYLESHEETS: Load the XSL stylesheets into the database
556 
557   PROCEDURE load_stylesheets;
558 
559 ---------------------------------------------------------------------
560 -- ARE_STYLESHEETS_LOADED: Are the XSL stylesheets loaded?
561 -- RETURNS: FALSE = definitely not
562 
563   FUNCTION are_stylesheets_loaded
564         RETURN BOOLEAN;
565 
566 ---------------------------------------------------------------------
567 -- SET_DEBUG: Set the internal debug switch.
568 -- PARAMETERS:
569 --      on_off          - new switch state.
570 
571   PROCEDURE set_debug(
572                 on_off          IN BOOLEAN,
573                 force_trace     IN BOOLEAN DEFAULT FALSE);
574 
578 --      schema   - the type's schema
575 -----------------------------------------------------------------------
576 -- PATCH_TYPEID: For transportable import, modify a type's typeid.
577 -- PARAMETERS:
579 --      name     - the type's name
580 --      typeid   - the type's typeid
581 --      hashcode - the type's hashcode
582 
583   PROCEDURE patch_typeid (
584                 schema          IN VARCHAR2,
585                 name            IN VARCHAR2,
586                 typeid          IN VARCHAR2,
587                 hashcode        IN VARCHAR2);
588 
589 -----------------------------------------------------------------------
590 -- CHECK_TYPE: For transportable import, check a type's definition (using the
591 --             hashcode) and typeid for a match against the one from the
592 --             export source database. This will catch differences in
593 --             a pre-existing type with the same name which already exists on
594 --             the import target database. This routine is called for each
595 --             referenced type right before a create table call is made.
596 --             If any of these calls raises an exception, then the table
597 --             is not created.
598 -- PARAMS:
599 --      schema     - schema of type
600 --      type_name  - type name
601 --      version    - internal stored verson of type
602 --      hashcode   - hashcode of the type defn
603 --      typeid     - subtype typeid ('' if no subtypes)
604 -- RETURNS: Nothing, returns if the hashcode and version match. Raises an
605 --          nnn exception if the type does not exist in the db or if the
606 --          type exists but the hash code and/or the version number does
607 --          not match.
608 --
609 PROCEDURE check_type    (schema     IN VARCHAR2,
610                          type_name  IN VARCHAR2,
611                          version    IN VARCHAR2,
612                          hashcode   IN VARCHAR2,
613                          typeid     IN VARCHAR2);
614 
615 
616 -----------------------------------------------------------------------
617 -- WRITE_CLOB : Write a CLOB to the trace file
618 
619   PROCEDURE write_clob(xml IN CLOB);
620 
621 ---------------------------------------------------------------------
622 -- IS_OMF: return 1 if name is an OMF, 0 otherwise.
623 -- PARAMETERS:
624 --      name    - a file name
625 -- RETURNS: number 0 or 1
626 
627   FUNCTION is_omf (
628                 name            IN  VARCHAR2
629                 )
630         RETURN number;
631 
632 ---------------------------------------------------------------------
633 -- table_tsnum: get canonical tablespace# for a table
634 --
635 -- PARAMETERS:
636 --      objnum    - object number of table
637 -- RETURNS: default tablespace for [root] parent table
638 
639   FUNCTION table_tsnum(
640                 objnum          IN NUMBER
641                 )
642         RETURN number;
643 
644 ---------------------------------------------------------------------
645 -- ref_par_level: returns the level number of a reference partitioned
646 --      child table.
647 -- PARAMETERS:
648 --      objnum    - object number of target table
649 -- RETURNS: number 1 or greater
650 
651   FUNCTION ref_par_level (
652                 objnum          IN NUMBER
653                 )
654         RETURN number;
655 
656   FUNCTION ref_par_level (
657                 objnum          IN NUMBER,
658                 properties      IN NUMBER
659                 )
660         RETURN number;
661 
662   FUNCTION ref_par_parent (
663                 objnum          IN NUMBER
664                 )
665         RETURN NUMBER;
666 
667 ----------------------------------------------------------------------------
668 -- GET_XMLTYPE_FMTS: Return formats of XMLType columns in a table
669 -- PARAMETERS:
670 --      objnum          - table object number
671 -- RETURNS:  0x01 = table has XMLType stored as CLOB
672 --           0x02 = table has XMLType stored OR or binary
673 
674   FUNCTION get_xmltype_fmts(
675                 objnum          IN number)
676          RETURN NUMBER;
677 
678 ----------------------------------------------------------------------------
679 -- BLOB2CLOB: Convert a column default replace null blob  to a clob
680 -- PARAMETERS:
681 --      tabobj          - tab object num
682 --      incolnum        - incolumn num
683 --      property        - col$.property
684 -- RETURNS:     clob ( this is hex value to pass to hextoraw as argument)
685 
686   FUNCTION blob2clob(
687                 tabobj          IN  NUMBER,
688                 incolnum        IN  NUMBER,
689                 property        IN  NUMBER)
690         RETURN CLOB;
691 
692 -----------------------------------------------------------------------
693 -- GET_BASE_INTCOL_NUM - Return intcol# of base column.
694 --                       For lobs associated with XMLType columns,
695 --                       this is the intcol# of the XMLType column;
696 --                       otherwise, intcol# of the first column with this col#
697 -- PARAMETERS:
698 --    objnum  - table obj#
699 --    colnum  - col# of this column
700 --    intcol  - intcol# of this column
701 --    typenum - type# of this column
702 
703   FUNCTION get_base_intcol_num (
704                 objnum          IN  NUMBER,
705                 colnum          IN  NUMBER,
706                 intcol          IN  NUMBER,
707                 typenum         IN  NUMBER
708                 )
709         RETURN NUMBER;
710 
711 -----------------------------------------------------------------------
712 -- GET_BASE_COL_TYPE - Return 1 if base column is udt,
713 --                            2 if base column is XMLType stored OR or CSX
717 -- PARAMETERS:
714 --                            3 if base column is XMLType stored as LOB
715 --                            0 if intcol = base column or base column not
716 --                                  udt or XMLType
718 --    objnum  - table obj#
719 --    colnum  - col# of this column
720 --    intcol  - intcol# of this column
721 --    typenum - type# of this column
722 
723   FUNCTION get_base_col_type (
724                 objnum          IN  NUMBER,
725                 colnum          IN  NUMBER,
726                 intcol          IN  NUMBER,
727                 typenum         IN  NUMBER
728                 )
729         RETURN NUMBER;
730 
731 -----------------------------------------------------------------------
732 -- GET_BASE_COL_NAME - return name of base xmltype column
733 -- PARAMETERS:
734 --    objnum  - table obj#
735 --    colnum  - col# of this column
736 --    intcol  - intcol# of this column
737 --    typenum - type# of this column
738 
739   FUNCTION get_base_col_name (
740                 objnum          IN  NUMBER,
741                 colnum          IN  NUMBER,
742                 intcol          IN  NUMBER,
743                 typenum         IN  NUMBER
744                 )
745         RETURN VARCHAR2;
746 
747 -----------------------------------------------------------------------
748 -- GET_EDITIONID        - Return the ID of a specified edition
749 --                        an exception will be raised on a non-existent editn
750 -- PARAMETERS:
751 --    edition   - edition name
752 
753   FUNCTION get_editionid (
754                 edition         IN  VARCHAR2
755                 )
756         RETURN NUMBER;
757 
758 ---------------------------------------------------------------------
759 -- GET_INDEX_INTCOL_PARSE - Parse default_val_clob and get intcol# in table
760 --                        - of column on which index is defined
761 -- PARAMETERS:
762 --    obj_num             - base table object #
763 --    intcol_num          - intcol# from icol$
764 --    default_val_clob    - default_val from col$
765 --
766 
767   FUNCTION get_index_intcol_parse(obj_num IN NUMBER,
768                                   intcol_num in NUMBER,
769                                   default_val_clob in CLOB)
770         RETURN NUMBER;
771 
772 ---------------------------------------------------------------------
773 -- GET_INDEX_INTCOL - Get intcol# in table of column on which index is
774 --                    defined (need special handling for xmltype cols)
775 -- PARAMETERS:
776 --      obj_num         - base table object #
777 --      intcol_num      - intcol# from icol$
778 --
779 
780   FUNCTION get_index_intcol(obj_num IN NUMBER,
781                             intcol_num in NUMBER)
782         RETURN NUMBER;
783 
784 ---------------------------------------------------------------------
785 -- HAS_TSTZ_COLS - Determine whether a table has data of type DTYSTZ
786 --                 (type# = 181): "TIMESTAMP WITH TIME ZONE"
787 --                 If so, data pump may have to convert the data.
788 --                 The data may be in a top-level column, an object column,
789 --                 or a varray.
790 -- PARAMETERS:
791 --      obj_num         - table object #
792 -- RETURNS:
793 --      'Y' - it does
794 --      'N' - it does not
795 
796   FUNCTION has_tstz_cols(obj_num IN NUMBER)
797         RETURN CHAR;
798 
799 ---------------------------------------------------------------------
800 -- HAS_TSTZ_ELEMENTS - Determine whether a varray type has TSTZ elements.
801 --                 This is a jacket function around utl_xml.haststz
802 -- PARAMETERS:
803 --      type_schema
804 --      type_name
805 -- RETURNS:
806 --      'Y' - it does
807 --      'N' - it does not
808 
809   FUNCTION has_tstz_elements(type_schema IN VARCHAR2,
810                              type_name   IN VARCHAR2)
811         RETURN CHAR;
812 
813 ---------------------------------------------------------------------
814 -- DELETE_XMLSCHEMA: call dbms_xmlschema.deleteSchema
815 --  to delete the named schema
816 
817   PROCEDURE DELETE_XMLSCHEMA(name varchar2);
818 
819 ---------------------------------------------------------------------
820 -- LOAD_XSD: call dbms_xmlschema.registerSchema
821 --  to register the named schema
822 
823   PROCEDURE LOAD_XSD(filename varchar2);
824 
825 ---------------------------------------------------------------------
826 -- GET_XMLCOLSET - return nested table of intcol numbers for OR storage
827 --              columns for xmltypes in table
828 --
829 -- PARAMETERS:
830 --    obj_num   - object number of table
831 
832   FUNCTION get_xmlcolset (obj_num IN NUMBER)
833         RETURN  ku$_XmlColSet_t;
834 
835 ---------------------------------------------------------------------
836 --  GET_XMLHIERARCHY   - return 'Y' if table is hierachy enabled, else null
837 --
838 -- PARAMETERS:
839 --    schema    - owner of table
840 --    name      - name of table
841 
842   FUNCTION get_xmlhierarchy ( schema IN VARCHAR2, name IN VARCHAR2)
843         RETURN  CHAR;
844 
845 ---------------------------------------------------------------------
846 -- isXml - return number indicating if intcol is OR storage
847 --              column of an xmltype column in table
848 -- PARAMETERS:
849 --    obj_num   - object number of table
850 --    intcol    - column to be tested
851 -- RETURNS
852 --    0 = not part of xmltype column
853 --    1 = is part of xmltype column
854 
855   FUNCTION isXml (obj_num IN NUMBER, intcol IN NUMBER) return NUMBER;
856 
857 ---------------------------------------------------------------------
861 --    nt_num    - nt number of nested table
858 -- isXml - another variant, starting with nested table
859 --              column of an xmltype column in table
860 -- PARAMETERS:
862 -- RETURNS
863 --    0 = not part of xmltype column
864 --    1 = is part of xmltype column
865 
866   FUNCTION isXml (nt_num IN NUMBER) return NUMBER;
867 
868 ---------------------------------------------------------------------
869 -- IS_SCHEMANAME_EXISTS - Return 1 if schema name exists in trigger definition
870 --                               0 other wise
871 -- PARAMETERS:
872 --    tdefinition   - Trigger definition
873 
874   FUNCTION is_schemaname_exists(tdefinition varchar2)
875         RETURN NUMBER;
876 
877 ---------------------------------------------------------------------
878 -- GET_MARKER - Return the current marker number
879 -- PARAMETERS:
880 --    none
881 
882   FUNCTION get_marker
883         RETURN NUMBER;
884 
885 -- GET_STRM_MINVER: Retrieve stream minor version based on job version
886 -- RETURNS: version number
887 
888  FUNCTION get_strm_minver
889         RETURN CHAR;
890 
891 ---------------------------------------------------------------------
892 -- SET_BLOCK_ESTIMATE - set state for estimate phase
893 -- PARAMETERS:
894 --      value - TRUE  = estimate=blocks
895 --              FALSE = estimate=statistics
896 
897   PROCEDURE set_block_estimate(value IN BOOLEAN);
898 
899 
900 ---------------------------------------------------------------------
901 -- GET_ANYDATA_COLSET - return nested table of type names for unpacked
902 --              ADT columns contained in an opaque column
903 --
904 -- PARAMETERS:
905 --    objnum    - object number of table
906 --    colnum    - number of current column (c.col#)
907 --    colcnt    - number of columns in the input column list
908 --    col_list  - list of intcol#s of columns storing unpacked ADT cols - each
909 --                intcol# is stored as a ub2
910 --
911 -- OUTPUT:
912 --    This function returns an AnyData Type list to the caller.  Each element
913 --    in the list contains one or more type names.  This list will be used to
914 --    generate the Alter table statements for unpacked types.  One Alter table
915 --    statement will be generated for each item in the list.  The reason for
916 --    multiple Alters instead of just one statement is to duplicate exactly
917 --    the way that the types were unpacked when the table was created.  This
918 --    is especially important for transportable tablespaces so that the
919 --    dictionary tables will accurately reflect the table layout in the table-
920 --    space.
921 --
922 FUNCTION get_anydata_colset(objnum IN NUMBER, colnum IN NUMBER,
923                             colcnt IN NUMBER, col_list RAW)
924        RETURN ku$_Unpacked_AnyData_t;
925 
926 
927 ---------------------------------------------------------------------
928 -- GET_ATTRNAME2 - Another attribute name for underlying columns of an
929 --                 unpacked opaque type column.
930 --
931 -- DESCRIPTION: This purpose for generating another attribute name for such
932 --              columns is due to the fact that these columns (even their
933 --              attribute names) are system generated.  This new alternate
934 --              name removes the system generated part of the name and
935 --              replaces it with the type name and its owner.  This will
936 --              allow the differ (if needed) to match the columns based on
937 --              this name.
938 --
939 -- PARAMETERS:
940 --    obj_num   - object number of table
941 --    intcolnum - currrent column's intcol#
942 --    colnum    - current column's col#
943 
944 FUNCTION get_attrname2(objnum IN NUMBER, intcolnum IN NUMBER, colnum IN NUMBER)
945        RETURN VARCHAR2;
946 
947 ---------------------------------------------------------------------
948 -- LOAD_TEMP_TABLE - copy sys.x$ktfbue into a temporary table
949 --  for subsequent use in computing bytes allocated.
950 --  Using the temporary table is much faster.
951 
952   PROCEDURE load_temp_table;
953 
954 ---------------------------------------------------------------------
955 -- BLOCK_ESTIMATE - calculate bytes_allocated using BLOCKS method
956 -- PARAMETERS:
957 --      o_num           - object #
958 --      view_num        - which view to use
959 --                         1 = ku$_htable_bytes_alloc_view
960 --                         2 = ku$_htpart_bytes_alloc_view
961 --                         3 = ku$_htspart_bytes_alloc_view
962 --                         4 = ku$_iotable_bytes_alloc_view
963 --                         5 = ku$_iotpart_bytes_alloc_view
964 --                         6 = ku$_ntable_bytes_alloc_view
965 --                         7 = ku$_eqntable_bytes_alloc_view
966 
967   FUNCTION block_estimate(o_num IN NUMBER,
968                           view_num IN NUMBER)
969         RETURN NUMBER;
970 
971 -- BYTES_ALLOC - calculate bytes allocated from x$ktfbue
972 --  using the temporary table if it has been initialized.
973 -- PARAMETERS:
974 --    ts_num            - tablespace # for this segment
975 --    file_num          - segment header file number
976 --    block_num         - segment header block number
977 --    block_size        - blocksize
978 -- RETURNS:
979 --    bytes allocated
980 
981   FUNCTION bytes_alloc(ts_num       IN NUMBER,
982                        file_num     IN NUMBER,
983                        block_num    IN NUMBER,
984                        block_size   IN NUMBER)
985         RETURN NUMBER;
986 
987 ---------------------------------------------------------------------
988 -- GET_TABPART_TS - get a ts# for a table (sub)partition
989 --   (used by dbms_metadata.in_tsnum_2
990 -- PARAMETERS:
991 --    obj_num    - obj# for table
992 
993   FUNCTION get_tabpart_ts (
994                 OBJ_NUM  IN NUMBER )
995         RETURN NUMBER;
996 
997 ---------------------------------------------------------------------
998 -- GET_INDPART_TS - get a ts# for an index (sub)partition
999 --   (used by ku$_index_view
1000 -- PARAMETERS:
1001 --    obj_num    - obj# for table
1002 
1003   FUNCTION get_indpart_ts (
1004                 OBJ_NUM  IN NUMBER )
1005         RETURN NUMBER;
1006 
1007 ---------------------------------------------------------------------
1008 -- GET_PART_LIST         - get ordered list of partition numbers,
1009 --                         or partition base object numbers
1010 --
1011 -- PARAMETERS:
1012 --      PARTYPE - 1 - tabpart
1013 --                2 - tabcompart
1014 --                3 - tabsubpart
1015 --                4 - indpart
1016 --                5 - indcompart
1017 --                6 - indsubpart
1018 --                7 - lobfrag
1019 --                8 - lobcomppart
1020 --                Values above +100 are used to fetch the set of base
1021 --                 object numbers for the corresponds type.
1022 --      BOBJ_NUM - base object number of which this is for partitions
1023 --      CNT      - (OUT) number of partitions in base objectrows returned
1024 --
1025 -- return t_num_coll - ordered list o partition number
1026 
1027 
1028 
1029   FUNCTION get_part_list (
1030                 PARTYPE  IN NUMBER,
1031                 BOBJ_NUM IN NUMBER,
1032                 CNT     OUT NUMBER  )
1033         RETURN dbms_metadata_int.t_num_coll;
1034 
1035 ---------------------------------------------------------------------
1036 -- GLO
1037 --
1038 -- Description: See bug 12866600.
1039 --
1040 -- Input:
1041 --      raw
1042 --
1043 -- Return:
1044 --      raw
1045 --
1046   FUNCTION glo (inval IN raw)
1047         RETURN raw;
1048 
1049 --+
1050 -- Fetch_Stat
1051 --
1052 -- Description: This procedure will fetch the XML from the metadata api for
1053 --              the SYS.IMPDP_STATS table
1054 --
1055 -- Caller:      This procedure is called from PREPARE_DATA_IMP if the XML
1056 --              needs to be refetched.
1057 --
1058 --  Implicit Inputs:
1059 --      None
1060 --
1061 -- Inputs:
1062 --      None
1063 --
1064 --  Implicit Outputs:
1065 --      None
1066 --
1067 -- Outputs:
1068 --      xml_clob for sys.impdp_stats
1069 --+
1070 PROCEDURE FETCH_STAT
1071   (stat_clob    IN OUT   CLOB);
1072 
1073 ---------------------------------------------------------------------
1074 -- FUNC_INDEX_DEFAULT  - get default$ from col$ for a func index
1075 --                       converting any null bytes to 'CHR(0)'
1076 -- PARAMETERS:
1077 --      length          - value of col$.deflength
1078 --      row             - rowid of the row in COL$
1079 -- RETURNS:     LONG value converted to VARCHAR2
1080 --              with any null byte converted to the string 'CHR(0)'
1081 --              if length <= 32000, otherwise NULL
1082 -- NOTE: This routine is adapted from 'func_index_default' in
1083 --       prvtpexp.sql (used by original exp).  It is required
1084 --       for bug 13386193.
1085 
1086   FUNCTION func_index_default(
1087                 length          IN  NUMBER,
1088                 row             IN  ROWID)
1089         RETURN VARCHAR2;
1090 
1091 -- FUNC_INDEX_DEFAULTC  - get default$ from col$ for a func index
1092 --                       converting any null bytes to 'CHR(0)'
1093 --   (This is the same as the above routine with a different return datatype)
1094 -- PARAMETERS:
1095 --      length          - value of col$.deflength
1096 --      row             - rowid of the row in COL$
1097 -- RETURNS:     LONG value converted to temporary CLOB
1098 --              with any null byte converted to the string 'CHR(0)'
1099 --              if length <= 32000, otherwise NULL
1100 -- NOTE: This routine is adapted from 'func_index_default' in
1101 --       prvtpexp.sql (used by original exp).  It is required
1102 --       for bug 13386193.
1103 
1104   FUNCTION func_index_defaultc(
1105                 length          IN  NUMBER,
1106                 row             IN  ROWID)
1107         RETURN CLOB;
1108 
1109 END DBMS_METADATA_UTIL;