1 PACKAGE dbms_metadata AUTHID CURRENT_USER AS
2 ---------------------------------------------------------------------
3 -- Overview
4 -- This pkg implements the mdAPI, a means to retrieve the aggregated
5 -- definitions of database objects as either XML docs. or their creation DDL,
6 -- or to submit the XML documents to execute the DDL.
7 ---------------------------------------------------------------------
8 -- SECURITY
9 -- This package is owned by SYS with execute access granted to PUBLIC.
10 -- It runs with invokers rights, i.e., with the security profile of
11 -- the caller. It calls DBMS_METADATA_INT to perform privileged
12 -- functions.
13 -- The object views defined in catmeta.sql implement the package's security
14 -- policy via the WHERE clause on the public views which include syntax to
15 -- control user access to metadata: if the current user is SYS or has
16 -- SELECT_CATALOG_ROLE, then all objects are visible; otherwise, only
17 -- objects in the schema of the current user are visible.
18
19 --------------------
20 -- PUBLIC CONSTANTS
21 --
22 SESSION_TRANSFORM CONSTANT BINARY_INTEGER := -1;
23 SESSION_HANDLE CONSTANT BINARY_INTEGER := -1;
24
25 MAX_PROCOBJ_RETLEN CONSTANT BINARY_INTEGER := 32767;
26 NEWBLOCK_CONTINUE CONSTANT NUMBER := 0;
27 NEWBLOCK_BEGIN CONSTANT NUMBER := 1;
28 NEWBLOCK_APPEND CONSTANT NUMBER := -2;
29
30 MARKER_PRE_SYSTEM CONSTANT NUMBER := 1;
31 MARKER_PRE_SCHEMA CONSTANT NUMBER := 2;
32 MARKER_PRE_INSTANCE CONSTANT NUMBER := 3;
33 MARKER_POST_SYSTEM CONSTANT NUMBER := 4;
34 MARKER_POST_SCHEMA CONSTANT NUMBER := 5;
35 MARKER_EARLY_POST_INSTANCE
36 CONSTANT NUMBER := 6;
37 MARKER_NORMAL_POST_INSTANCE
38 CONSTANT NUMBER := 8;
39 MARKER_POST_INSTANCE CONSTANT NUMBER := 7;
40 MARKER_FINAL_POST_INSTANCE
41 CONSTANT NUMBER := 7;
42 MARKER_STATISTICS CONSTANT NUMBER := 10;
43
44 -- flags definitions for 'put'
45 PUT_RAISE_EXCEPTION CONSTANT BINARY_INTEGER := 1;
46 --
47 -- The following types are used in the 'fast convert' interface that returns
48 -- a single CLOB and collection of records containing a position/length for DDL
49 -- in the clob and a fixed set of parse items. There is a parallel
50 -- between these PL/SQL types and the ku$_ddl* / _multi_ddl* types defined
51 -- above; except thie improves performance, at the cost of flexibility.
52 --
53 -- This is only intended for use by datapump (worker).
54
55 --------------------
56 -- PUBLIC PL/SQL TYPE DEFINITIONS
57 --
58 TYPE offset IS RECORD
59 ( pos PLS_INTEGER,
60 len PLS_INTEGER,
61 grantor VARCHAR2(30),
62 bind_pattern VARCHAR2(30),
63 alt_connect_type VARCHAR2(4),
64 has_tstz_cols VARCHAR2(30),
65 has_virtual_columns VARCHAR2(30),
66 type_alter_type_cnt VARCHAR2(30),
67 dblpwx VARCHAR2(256),
68 dblapwx VARCHAR2(256),
69 no_table_lock VARCHAR2(1)
70 );
71
72 TYPE objddl IS TABLE OF offset INDEX BY BINARY_INTEGER;
73
74 TYPE T_VAR_COLL IS TABLE OF VARCHAR2(60) INDEX BY BINARY_INTEGER;
75
76 TYPE multiobjects IS TABLE OF objddl INDEX BY BINARY_INTEGER;
77
78 -------------
79 -- EXCEPTIONS
80 --
81 invalid_argval EXCEPTION;
82 PRAGMA EXCEPTION_INIT(invalid_argval, -31600);
83 invalid_argval_num NUMBER := -31600;
84 -- "Invalid input value %s for parameter %s in function %s"
85 -- *Cause: A NULL or invalid value was supplied for the parameter.
86 -- *Action: Correct the input value and try the call again.
87
88 invalid_operation EXCEPTION;
89 PRAGMA EXCEPTION_INIT(invalid_operation, -31601);
90 invalid_operation_num NUMBER := -31601;
91 -- "Function %s cannot be called now that fetch has begun"
92 -- *Cause: The function was called after the first call to FETCH_xxx.
93 -- *Action: Correct the program.
94
95 inconsistent_args EXCEPTION;
96 PRAGMA EXCEPTION_INIT(inconsistent_args, -31602);
97 inconsistent_args_num NUMBER := -31602;
98 -- "parameter %s value \"%s\" in function %s inconsistent with %s"
99 -- "Value \"%s\" for parameter %s in function %s is inconsistent with %s"
100 -- *Cause: The parameter value is inconsistent with another value specified
101 -- by the program. It may be not valid for the the object type
102 -- associated with the OPEN context, or it may be of the wrong
103 -- datatype: a boolean rather than a text string or vice versa.
104 -- *Action: Correct the program.
105
106 object_not_found EXCEPTION;
107 PRAGMA EXCEPTION_INIT(object_not_found, -31603);
108 object_not_found_num NUMBER := -31603;
109 -- "object \"%s\" of type %s not found in schema \"%s\""
110 -- *Cause: The specified object was not found in the database.
111 -- *Action: Correct the object specification and try the call again.
112
113 invalid_object_param EXCEPTION;
114 PRAGMA EXCEPTION_INIT(invalid_object_param, -31604);
115 invalid_object_param_num NUMBER := -31604;
116 -- "invalid %s parameter \"%s\" for object type %s in function %s"
117 -- *Cause: The specified parameter value is not valid for this object type.
118 -- *Action: Correct the parameter and try the call again.
119
120 inconsistent_operation EXCEPTION;
121 PRAGMA EXCEPTION_INIT(inconsistent_operation, -31607);
122 inconsistent_operation_num NUMBER := -31607;
123 -- "Function %s is inconsistent with transform."
124 -- *Cause: Either (1) FETCH_XML was called when the "DDL" transform
125 -- was specified, or (2) FETCH_DDL was called when the
126 -- "DDL" transform was omitted.
127 -- *Action: Correct the program.
128
129 object_not_found2 EXCEPTION;
130 PRAGMA EXCEPTION_INIT(object_not_found2, -31608);
131 object_not_found2_num NUMBER := -31608;
132 -- "specified object of type %s not found"
133 -- (Used by GET_DEPENDENT_xxx and GET_GRANTED_xxx.)
134 -- *Cause: The specified object was not found in the database.
135 -- *Action: Correct the object specification and try the call again.
136
137 stylesheet_load_error EXCEPTION;
138 PRAGMA EXCEPTION_INIT(stylesheet_load_error, -31609);
139 stylesheet_load_error_num NUMBER := -31609;
140 -- "error loading file %s from file system directory \'%s\'"
141 -- *Cause: The installation script initmeta.sql failed to load
142 -- the named file from the file system directory into the database.
143 -- *Action: Examine the directory and see if the file is present
144 -- and can be read.
145
146 sql_error EXCEPTION;
147 PRAGMA EXCEPTION_INIT(sql_error, -31642);
148 sql_error_num NUMBER := -31642;
149 -- "the following SQL statement failed: %s"
150 -- *Cause: An internal error was generated from package DBMS_METADATA.
151 -- *Action: Call Oracle Support.
152
153 dbmsjava_error EXCEPTION;
154 PRAGMA EXCEPTION_INIT(dbmsjava_error, -39128);
155 dbmsjava_error_num NUMBER := -39128;
156 -- "Unexpected DbmsJava error %d from statement %s"
157 -- *Cause: The error was returned from a call to a DbmsJava procedure.
158 -- *Action: Record the accompanying messages and report this as a Data Pump
159 -- internal error to customer support.
160
161 ---------------------------
162 -- PROCEDURES AND FUNCTIONS
163 --
164 -- OPEN: Specifies the type of object whose metadata is to be retrieved.
165 -- PARAMETERS:
166 -- object_type - Identifies the type of objects to be retrieved; i.e.,
167 -- TABLE, INDEX, etc. This determines which view is selected.
168 -- version - The version of the objects' metadata to be fetched.
169 -- To be used in downgrade scenarios: Objects in the DB that are
170 -- incompatible with an older specified version are not returned.
171 -- Values can be 'COMPATIBLE' (default), 'LATEST' or a specific
172 -- version number.
173 -- model - The view of the metadata, such as Oracle proprietary,
174 -- ANSI99, etc. Currently only 'ORACLE' is supported.
175 -- network_link - The name of a database link to the database
176 -- whose data is to be retrieved. If NULL (default), metadata
177 -- is retrieved from the database on which the caller is running.
178 --
179 -- RETURNS:
180 -- A handle to be used in subsequent calls to SET_FILTER, SET_COUNT,
181 -- ADD_TRANSFORM, GET_QUERY, SET_PARSE_ITEM, FETCH_xxx and CLOSE.
182 -- EXCEPTIONS:
183 -- INVALID_ARGVAL - a NULL or invalid value was supplied for an input
184 -- parameter.
185
186 FUNCTION open (
187 object_type IN VARCHAR2,
188 version IN VARCHAR2 DEFAULT 'COMPATIBLE',
189 model IN VARCHAR2 DEFAULT 'ORACLE',
190 network_link IN VARCHAR2 DEFAULT NULL)
191 RETURN NUMBER;
192
193 -- SET_FILTER: Specifies restrictions on the objects whose metadata
194 -- is to be retrieved.
195 -- This function is overloaded: the filter value can be a varchar2,
196 -- number or boolean.
197 -- PARAMETERS:
198 -- handle - Context handle from previous OPEN call.
199 -- name - Name of the filter.
200 -- value - Value of the filter.
201 -- object_type_path- Path name of object types to which
202 -- the filter applies.
203
204 PROCEDURE set_filter (
205 handle IN NUMBER,
206 name IN VARCHAR2,
207 value IN VARCHAR2,
208 object_type_path IN VARCHAR2 DEFAULT NULL);
209
210 PROCEDURE set_filter (
211 handle IN NUMBER,
212 name IN VARCHAR2,
213 value IN BOOLEAN DEFAULT TRUE,
214 object_type_path IN VARCHAR2 DEFAULT NULL);
215
216 PROCEDURE set_filter (
217 handle IN NUMBER,
218 name IN VARCHAR2,
219 value IN NUMBER,
220 object_type_path IN VARCHAR2 DEFAULT NULL);
221
222
223 -- SET_COUNT: Specifies the number of objects to be returned in a single
224 -- FETCH_xxx call.
225 -- PARAMETERS:
226 -- handle - Context handle from previous OPEN call.
227 -- value - Number of objects to retrieve.
228 -- object_type_path- Path name of object types to which
229 -- the count applies.
230
231 PROCEDURE set_count (
232 handle IN NUMBER,
233 value IN NUMBER,
234 object_type_path IN VARCHAR2 DEFAULT NULL);
235
236
237 -- SET_XMLFORMAT: Specifies formatting attributes for XML output.
238 -- PARAMETERS:
239 -- handle - Context handle from previous OPEN call.
240 -- name - Attribute to set. (Only 'PRETTY' is supported.)
241 -- value - Value of the attribute.
242
243 PROCEDURE set_xmlformat (
244 handle IN NUMBER,
245 name IN VARCHAR2,
246 value IN BOOLEAN DEFAULT TRUE);
247
248 -- GET_QUERY: Return the text of the query (or queries) that will be
249 -- used by FETCH_xxx. This function is provided to aid
250 -- in debugging.
251 -- PARAMETERS: handle - Context handle from previous OPEN call.
252 -- RETURNS: Text of the query.
253
254 FUNCTION get_query (
255 handle IN NUMBER)
256 RETURN VARCHAR2;
257
258 -- SET_PARAMETER: Specify parameter values which affect the operation.
259 -- PARAMETERS:
260 -- handle - Context handle from previous OPEN call.
261 -- name - Name of the parameter.
262 -- value - Value of the parameter.
263
264 PROCEDURE set_parameter (
265 handle IN NUMBER,
266 name IN VARCHAR2,
267 value IN BOOLEAN DEFAULT TRUE);
268
269
270 -- SET_PARSE_ITEM: Enables output parsing and specifies an object attribute
271 -- to be parsed and returned
272 -- PARAMETERS:
273 -- handle - Context handle from previous OPEN call.
274 -- name - Attribute name.
275 -- object_type- Object type to which the transform applies.
276
277 PROCEDURE set_parse_item (
278 handle IN NUMBER,
279 name IN VARCHAR2,
280 object_type IN VARCHAR2 DEFAULT NULL);
281
282
283 -- ADD_TRANSFORM : Specify a transform to be applied to the XML representation
284 -- of objects processed by FETCH_xxx, CONVERT or PUT.
285 -- PARAMETERS: handle - Context handle from previous OPEN or OPENW call.
286 -- name - The name of the transform: Can be 'DDL' to generate
287 -- creation DDL or a URI pointing to a stylesheet,
288 -- either external or internal to the DB (the latter
289 -- being an Xpath spec. starting with '/oradb').
290 -- encoding- If name is a URI, this specifies the encoding of the
291 -- target stylesheet. If left NULL, then if uri starts
292 -- with '/oradb', then the database char. set is used;
293 -- otherwise, 'UTF-8'. Use 'US-ASCII' for better perf.
294 -- if you can. May be any valid NLS char. set name.
295 -- Ignored if name is an internal transform name (like
296 -- DDL), not a URI.
297 -- object_type- Object type to which the transform applies.
298 --
299 -- NOTE: If name is an intra-DB uri (ie, /oradb) that points to an NCLOB
300 -- column or a CLOB with an encoding different from the database charset,
301 -- you must explicitly specify the encoding.
302 -- RETURNS: An opaque handle to the transform to be used in subsequent
303 -- calls to SET_TRANSFORM_PARAM.
304
305 FUNCTION add_transform (
306 handle IN NUMBER,
307 name IN VARCHAR2,
308 encoding IN VARCHAR2 DEFAULT NULL,
309 object_type IN VARCHAR2 DEFAULT NULL)
310 RETURN NUMBER;
311
312
313 -- SET_TRANSFORM_PARAM: Specifies a value for a parameter to the XSL-T
314 -- stylesheet identified by handle.
315 -- This procedure is overloaded: the parameter value can be a varchar2,
316 -- a number or a boolean.
317 -- PARAMETERS:
318 -- transform_handle - Handle from previous ADD_TRANSFORM call.
319 -- name - Name of the parameter.
320 -- value - Value for the parameter.
321 -- object_type - Object type to which the transform param applies.
322
323 PROCEDURE set_transform_param (
324 transform_handle IN NUMBER,
325 name IN VARCHAR2,
326 value IN VARCHAR2,
327 object_type IN VARCHAR2 DEFAULT NULL);
328
329 PROCEDURE set_transform_param (
330 transform_handle IN NUMBER,
331 name IN VARCHAR2,
332 value IN BOOLEAN DEFAULT TRUE,
333 object_type IN VARCHAR2 DEFAULT NULL);
334
335 PROCEDURE set_transform_param (
336 transform_handle IN NUMBER,
337 name IN VARCHAR2,
338 value IN NUMBER,
339 object_type IN VARCHAR2 DEFAULT NULL);
340
341 -- SET_REMAP_PARAM: Specifies a value for a parameter to the XSL-T
342 -- stylesheet identified by handle.
343 -- PARAMETERS:
344 -- transform_handle - Handle from previous ADD_TRANSFORM call.
345 -- name - Name of the parameter.
346 -- old_value - Old value for the remapping
347 -- new_value - New value for the remapping
348 -- object_type - Object type to which the transform param applies.
349
350 PROCEDURE set_remap_param (
351 transform_handle IN NUMBER,
352 name IN VARCHAR2,
353 old_value IN VARCHAR2,
354 new_value IN VARCHAR2,
355 object_type IN VARCHAR2 DEFAULT NULL);
356
357 -- FETCH_XML: Return metadata for objects as XML documents. This version
358 -- can return multiple objects per call (when the SET_COUNT
359 -- 'value' parameter > 1).
360 -- PARAMETERS: handle - Context handle from previous OPEN call.
361 -- RETURNS: XML metadata for the objects as an XMLType, or NULL if all
362 -- objects have been fetched.
363 -- EXCEPTIONS: Throws an exception if DDL transform has been added
364
365 FUNCTION fetch_xml (handle IN NUMBER)
366 RETURN sys.XMLType;
367
368
369 -- FETCH_DDL: Return metadata as DDL.
370 -- More than one DDL statement may be returned.
371 -- RETURNS: Metadata for the objects as one or more DDL statements
372 -- PARAMETERS: handle - Context handle from previous OPEN call.
373 -- EXCEPTIONS: Throws an exception if DDL transform was not added.
374
375 FUNCTION fetch_ddl (
376 handle IN NUMBER)
377 RETURN sys.ku$_ddls;
378
379
380 --************* TEMPORARY ************************
381 -- FETCH_DDL_TEXT: Return DDL metadata as VARCHAR2.
382 -- NOTE: This is a temporary API for logical standby.
383 -- It is needed because LOBs and objects cannot
384 -- currently (8.2) be returned over dblinks.
385 -- RETURNS: Metadata for the object as one DDL statement
386 -- PARAMETERS: handle - Context handle from previous OPEN call.
387 -- partial - set to 1 if the statement was too long
388 -- to fit in the VARCHAR2; the next call will
389 -- return the next piece of the metadata.
390 -- EXCEPTIONS: Throws an exception if DDL transform was not added.
391
392 FUNCTION fetch_ddl_text (
393 handle IN NUMBER,
394 partial OUT NUMBER)
395 RETURN VARCHAR2;
396 --************* TEMPORARY ************************
397
398
399 -- FETCH_CLOB: Return metadata for object (transformed or not) as a CLOB.
400 -- PARAMETERS: handle - Context handle from previous OPEN call.
401 -- cache_lob - TRUE = read LOB into buffer cache
402 -- lob_duration - either DBMS_LOB.SESSION (default)
403 -- or DBMS_LOB.CALL, the duration for the termporary lob
404 -- RETURNS: XML metadata for the objects as a CLOB, or NULL if all
405 -- objects have been fetched.
406
407 FUNCTION fetch_clob (handle IN NUMBER,
408 cache_lob IN BOOLEAN DEFAULT TRUE,
409 lob_duration IN PLS_INTEGER DEFAULT DBMS_LOB.SESSION)
410 RETURN CLOB;
411
412
413 -- PROCEDURE FETCH_CLOB: Same as above but with IN/OUT NOCOPY CLOB. CLOB
414 -- must be pre-created prior to call.
415 -- PARAMETERS: handle - (IN) Context handle from previous OPENC call.
416 -- xmldoc - (IN OUT) previously allocated CLOB to hold the
417 -- returned diff document.
418
419 PROCEDURE fetch_clob (
420 handle IN NUMBER,
421 xmldoc IN OUT NOCOPY CLOB);
422
423 -- NETWORK_OPEN: Do OPEN over network; negotiate protocol version
424 -- This function is called by the local server and
425 -- runs in the remote server.
426 -- PARAMETERS:
427 -- object_type - See 'OPEN'
428 -- version - See 'OPEN'
429 -- model - See 'OPEN'
430 -- client_version - The highest protocol version understood by
431 -- the caller.
432 -- protocol_version- The protocol version to be used in this session.
433 -- NETWORK_OPEN picks the highest protocol version
434 -- understood by both itself and the caller.
435 --
436 -- RETURNS:
437 -- A handle to be used in subsequent calls to SET_FILTER, SET_COUNT,
438 -- ADD_TRANSFORM, GET_QUERY, SET_PARSE_ITEM, FETCH_xxx and CLOSE.
439 -- EXCEPTIONS:
440 -- INVALID_ARGVAL - a NULL or invalid value was supplied for an input
441 -- parameter.
442
443 FUNCTION network_open (
444 object_type IN VARCHAR2,
445 version IN VARCHAR2 DEFAULT 'COMPATIBLE',
446 model IN VARCHAR2 DEFAULT 'ORACLE',
447 client_version IN NUMBER,
448 protocol_version OUT NUMBER)
449 RETURN NUMBER;
450
451 -- NETWORK_CALLOUTS: Execute callouts on remote instance
452 -- (These can't execute in the context of a remote function.)
453 -- PARAMETERS: handle - Context handle from previous OPEN call.
454
455 PROCEDURE network_callouts (
456 handle IN NUMBER );
457
458 -- NETWORK_FETCH_CLOB: Return metadata as VARCHAR2.
459 -- RETURNS: Metadata for the object
460 -- PARAMETERS: handle - Context handle from previous OPEN call.
461 -- do_xsl_parse - 1 = do parse the XSL way
462 -- partial - set to 1 if the statement was too long
463 -- to fit in the VARCHAR2; the next call will
464 -- return the next piece of the metadata.
465 -- parse_delim - the parse delimiter
466 -- do_callout - set to 1 if the next action is a callout
467 -- 0 otherwise
468 -- have_errors - set to 1 if procedural object/action code
469 -- raised an exception that should be fetched
470 -- 0 otherwise
471
472 FUNCTION network_fetch_clob (
473 handle IN NUMBER,
474 do_xsl_parse IN NUMBER,
475 partial OUT NUMBER,
476 parse_delim OUT VARCHAR2,
477 do_callout OUT NUMBER,
478 have_errors OUT NUMBER)
479 RETURN VARCHAR2;
480
481 -- NETWORK_FETCH_ERRORS: Serializes a ku$_vcnt into a VARCHAR2 for
482 -- network operations. (modeled on NETWORK_FETCH_PARSE, below)
483 -- RETURNS: VARCHAR2: A delimited series of error string
484 -- PARAMETERS: handle - Context handle from previous OPEN call.
485 -- cnt - Number of errors returned this iteration
486 -- partial - set to 1 if there's more to come
487 -- seqno - Seq. number for current member of heterogeneous obj.
488 -- path - Path for current member of heterogeneous obj.
489 --
490 -- IMPLICIT INPUTS: pkg-scoped parse_pattern established by network_fetch_clob
491
492 FUNCTION network_fetch_errors (
493 handle IN NUMBER,
494 cnt OUT NUMBER,
495 partial OUT NUMBER,
496 seqno OUT NUMBER,
497 path OUT VARCHAR2)
498 RETURN VARCHAR2;
499
500 -- NETWORK_FETCH_PARSE: Serializes a ku$_parsed_items into a VARCHAR2 for
501 -- network operations.
502 -- RETURNS: varchar2 is a delimited series of ku$_parsed_item attributes
503 -- PARAMETERS: handle - Context handle from previous OPEN call.
504 -- cnt - Number of parse items returned this iteration
505 -- partial - set to 1 if there's more to come
506 -- seqno - Seq. number for current member of heterogeneous obj.
507 -- path - Path for current member of heterogeneous obj.
508
509 FUNCTION network_fetch_parse (
510 handle IN NUMBER,
511 cnt OUT NUMBER,
512 partial OUT NUMBER,
513 seqno OUT NUMBER,
514 path OUT VARCHAR2)
515 RETURN VARCHAR2;
516
517 ---------------------------------------------------------------------
518 -- FETCH_XML_CLOB: Procedure variant with IN/OUT NOCOPY CLOB.
519 -- Also returns nested table of parsed items, object type path.
520 -- PARAMETERS: handle - Context handle from previous OPEN call.
521 -- doc - XML metadata for the objects or NULL if all
522 -- objects have been fetched.
523 -- parsed_items - Table of parsed items.
524 -- object_type_path - for heterogeneous object types the full
525 -- path name of the object type for the object(s) returned;
526 -- NULL if handle is for a homogeneous object type
527 -- seqno - for heterogeneous object types the sequence
528 -- number of the object type in the heterogeneous collection;
529 -- NULL if handle is for a homogeneous object type
530 -- procobj_errors - nested table of varchar2 - each entry
531 -- contains an exception raised by procedural action code.
532 -- NULL if no exceptions raised
533 -- EXCEPTIONS: Throws an exception if DDL transform has been added.
534
535 PROCEDURE fetch_xml_clob (
536 handle IN NUMBER,
537 doc IN OUT NOCOPY CLOB,
538 parsed_items IN OUT NOCOPY sys.ku$_parsed_items,
539 object_type_path OUT VARCHAR2);
540
541 PROCEDURE fetch_xml_clob (
542 handle IN NUMBER,
543 doc IN OUT NOCOPY CLOB,
544 parsed_items IN OUT NOCOPY sys.ku$_parsed_items,
545 object_type_path OUT VARCHAR2,
546 seqno OUT NUMBER,
547 procobj_errors OUT sys.ku$_vcnt);
548
549 -- CLOSE: Cleanup all context associated with handle.
550 -- PARAMETERS: handle - Context handle from previous OPEN call.
551
552 PROCEDURE CLOSE (handle IN NUMBER);
553
554
555 -- GET_XML: Return the metadata for a single object as XML.
556 -- This interface is meant for casual browsing (e.g., from SQLPlus)
557 -- vs. the programmatic OPEN / FETCH / CLOSE interfaces above.
558 -- PARAMETERS:
559 -- object_type - The type of object to be retrieved.
560 -- name - Name of the object.
561 -- schema - Schema containing the object. Defaults to
562 -- the caller's schema.
563 -- version - The version of the objects' metadata.
564 -- model - The object model for the metadata.
565 -- transform - XSL-T transform to be applied.
566 -- RETURNS: Metadata for the object as an NCLOB.
567
568 FUNCTION get_xml (
569 object_type IN VARCHAR2,
570 name IN VARCHAR2,
571 schema IN VARCHAR2 DEFAULT NULL,
572 version IN VARCHAR2 DEFAULT 'COMPATIBLE',
573 model IN VARCHAR2 DEFAULT 'ORACLE',
574 transform IN VARCHAR2 DEFAULT NULL)
575 RETURN CLOB;
576
577
578 -- GET_SXML: Return the metadata for a single object as SXML.
579 -- This interface is meant for casual browsing (e.g., from SQLPlus)
580 -- vs. the programmatic OPEN / FETCH / CLOSE interfaces above.
581 -- PARAMETERS:
582 -- object_type - The type of object to be retrieved.
583 -- name - Name of the object.
584 -- schema - Schema containing the object. Defaults to
585 -- the caller's schema.
586 -- version - The version of the objects' metadata.
587 -- model - The object model for the metadata.
588 -- transform - XSL-T transform to be applied.
589 -- RETURNS: Metadata for the object transformed to SXML as a CLOB.
590
591 FUNCTION get_sxml (
592 object_type IN VARCHAR2,
593 name IN VARCHAR2,
594 schema IN VARCHAR2 DEFAULT NULL,
595 version IN VARCHAR2 DEFAULT 'COMPATIBLE',
596 model IN VARCHAR2 DEFAULT 'ORACLE',
597 transform IN VARCHAR2 DEFAULT 'SXML')
598 RETURN CLOB;
599
600 -- GET_SXML_DDL: Return the metadata for a single object, convert it
601 -- to SXML, then convert the SXML to DDL.
602 -- Used for testing the SXML and SXMLDDL transforms.
603 -- PARAMETERS:
604 -- object_type - The type of object to be retrieved.
605 -- name - Name of the object.
606 -- schema - Schema containing the object. Defaults to
607 -- the caller's schema.
608 -- version - The version of the objects' metadata.
609 -- model - The object model for the metadata.
610 -- transform - XSL-T transform to be applied.
611 -- RETURNS: Metadata for the object transformed to SXML, then DDL,
612 -- as a CLOB.
613
614 FUNCTION get_sxml_ddl (
615 object_type IN VARCHAR2,
616 name IN VARCHAR2,
617 schema IN VARCHAR2 DEFAULT NULL,
618 version IN VARCHAR2 DEFAULT 'COMPATIBLE',
619 model IN VARCHAR2 DEFAULT 'ORACLE',
620 transform IN VARCHAR2 DEFAULT 'SXMLDDL')
621 RETURN CLOB;
622
623 -- GET_DDL: Return the metadata for a single object as DDL.
624 -- This interface is meant for casual browsing (e.g., from SQLPlus)
625 -- vs. the programmatic OPEN / FETCH / CLOSE interfaces above.
626 -- PARAMETERS:
627 -- object_type - The type of object to be retrieved.
628 -- name - Name of the object.
629 -- schema - Schema containing the object. Defaults to
630 -- the caller's schema.
631 -- version - The version of the objects' metadata.
632 -- model - The object model for the metadata.
633 -- transform - XSL-T transform to be applied.
634 -- RETURNS: Metadata for the object transformed to DDL as a CLOB.
635
636 FUNCTION get_ddl (
637 object_type IN VARCHAR2,
638 name IN VARCHAR2,
639 schema IN VARCHAR2 DEFAULT NULL,
640 version IN VARCHAR2 DEFAULT 'COMPATIBLE',
641 model IN VARCHAR2 DEFAULT 'ORACLE',
642 transform IN VARCHAR2 DEFAULT 'DDL')
643 RETURN CLOB;
644
645 -- GET_DEPENDENT_XML: Return the metadata for objects dependent on a
646 -- base object as XML.
647 -- This interface is meant for casual browsing (e.g., from SQLPlus)
648 -- vs. the programmatic OPEN / FETCH / CLOSE interfaces above.
649 -- PARAMETERS:
650 -- object_type - The type of object to be retrieved.
651 -- base_object_name- Name of the base object.
652 -- base_object_schema- Schema containing the base object. Defaults to
653 -- the caller's schema.
654 -- version - The version of the objects' metadata.
655 -- model - The object model for the metadata.
656 -- transform - XSL-T transform to be applied.
657 -- object_count - maximum number of objects to return
658 -- RETURNS: Metadata for the object as a CLOB.
659
660 FUNCTION get_dependent_xml (
661 object_type IN VARCHAR2,
662 base_object_name IN VARCHAR2,
663 base_object_schema IN VARCHAR2 DEFAULT NULL,
664 version IN VARCHAR2 DEFAULT 'COMPATIBLE',
665 model IN VARCHAR2 DEFAULT 'ORACLE',
666 transform IN VARCHAR2 DEFAULT NULL,
667 object_count IN NUMBER DEFAULT 10000)
668 RETURN CLOB;
669
670 -- GET_DEPENDENT_SXML: Return the metadata for objects dependent on a
671 -- base object as XML.
672 -- This interface is meant for casual browsing (e.g., from SQLPlus)
673 -- vs. the programmatic OPEN / FETCH / CLOSE interfaces above.
674 -- PARAMETERS:
675 -- object_type - The type of object to be retrieved.
676 -- base_object_name- Name of the base object.
677 -- base_object_schema- Schema containing the base object. Defaults to
678 -- the caller's schema.
679 -- version - The version of the objects' metadata.
680 -- model - The object model for the metadata.
681 -- transform - XSL-T transform to be applied.
682 -- object_count - maximum number of objects to return
683 -- RETURNS: Metadata for the object as a CLOB.
684
685 FUNCTION get_dependent_sxml (
686 object_type IN VARCHAR2,
687 base_object_name IN VARCHAR2,
688 base_object_schema IN VARCHAR2 DEFAULT NULL,
689 version IN VARCHAR2 DEFAULT 'COMPATIBLE',
690 model IN VARCHAR2 DEFAULT 'ORACLE',
691 transform IN VARCHAR2 DEFAULT 'SXML',
692 object_count IN NUMBER DEFAULT 10000)
693 RETURN CLOB;
694
695 -- GET_DEPENDENT_DDL: Return the metadata for objects dependent on a
696 -- base object as DDL.
697 -- This interface is meant for casual browsing (e.g., from SQLPlus)
698 -- vs. the programmatic OPEN / FETCH / CLOSE interfaces above.
699 -- PARAMETERS:
700 -- object_type - The type of object to be retrieved.
701 -- base_object_name- Name of the base object.
702 -- base_object_schema- Schema containing the base object. Defaults to
703 -- the caller's schema.
704 -- version - The version of the objects' metadata.
705 -- model - The object model for the metadata.
706 -- transform - XSL-T transform to be applied.
707 -- object_count - maximum number of objects to return
708 -- RETURNS: Metadata for the object as a CLOB.
709
710 FUNCTION get_dependent_ddl (
711 object_type IN VARCHAR2,
712 base_object_name IN VARCHAR2,
713 base_object_schema IN VARCHAR2 DEFAULT NULL,
714 version IN VARCHAR2 DEFAULT 'COMPATIBLE',
715 model IN VARCHAR2 DEFAULT 'ORACLE',
716 transform IN VARCHAR2 DEFAULT 'DDL',
717 object_count IN NUMBER DEFAULT 10000)
718 RETURN CLOB;
719
720 -- GET_GRANTED_XML: Return the metadata for objects granted to a
721 -- grantee as XML.
722 -- This interface is meant for casual browsing (e.g., from SQLPlus)
723 -- vs. the programmatic OPEN / FETCH / CLOSE interfaces above.
724 -- PARAMETERS:
725 -- object_type - The type of object to be retrieved.
726 -- grantee - Name of the grantee.
727 -- version - The version of the objects' metadata.
728 -- model - The object model for the metadata.
729 -- transform - XSL-T transform to be applied.
730 -- object_count - maximum number of objects to return
731 -- RETURNS: Metadata for the object as a CLOB.
732
733 FUNCTION get_granted_xml (
734 object_type IN VARCHAR2,
735 grantee IN VARCHAR2 DEFAULT NULL,
736 version IN VARCHAR2 DEFAULT 'COMPATIBLE',
737 model IN VARCHAR2 DEFAULT 'ORACLE',
738 transform IN VARCHAR2 DEFAULT NULL,
739 object_count IN NUMBER DEFAULT 10000)
740 RETURN CLOB;
741
742 -- GET_GRANTED_DDL: Return the metadata for objects granted to a
743 -- grantee as DDL.
744 -- This interface is meant for casual browsing (e.g., from SQLPlus)
745 -- vs. the programmatic OPEN / FETCH / CLOSE interfaces above.
746 -- PARAMETERS:
747 -- object_type - The type of object to be retrieved.
748 -- grantee - Name of the grantee.
749 -- version - The version of the objects' metadata.
750 -- model - The object model for the metadata.
751 -- transform - XSL-T transform to be applied.
752 -- object_count - maximum number of objects to return
753 -- RETURNS: Metadata for the object as a CLOB.
754
755 FUNCTION get_granted_ddl (
756 object_type IN VARCHAR2,
757 grantee IN VARCHAR2 DEFAULT NULL,
758 version IN VARCHAR2 DEFAULT 'COMPATIBLE',
759 model IN VARCHAR2 DEFAULT 'ORACLE',
760 transform IN VARCHAR2 DEFAULT 'DDL',
761 object_count IN NUMBER DEFAULT 10000)
762 RETURN CLOB;
763
764 -- GET_DPSTRM_MD: Retrieve stream (i.e., table) metadata
765 -- for DataPump data layer.
766 -- PARAMETERS:
767 -- schema - the table's schema
768 -- name - the table's name
769 -- mdversion - the version of metadata to be extracted, one of
770 -- - COMPATIBLE (default) - version of metadata
771 -- corresponds to database compatibility level
772 -- - LATEST - corresponds to database version
773 -- - a specific database version
774 -- dpapiversion - the direct path API version (this value is stored
775 -- in the returned XML document)
776 -- doc - An XML document containing the stream metadata
777 -- for the table/partition.
778 -- network_link - The name of a database link to the database
779 -- whose data is to be retrieved. If NULL (default), metadata
780 -- is retrieved from the database on which the caller is running.
781 -- force_lob_be - if TRUE, clear bit 0x0200 of
782 -- COL_LIST/COL_LIST_ITEM/LOB_PROPERTY, i.e., force the metadata
783 -- to make the lob appear big endian.
784 -- force_no_encrypt - if TRUE, clear encryption bits in col$ properties:
785 -- 0x04000000 = 67108864 = Column is encrypted
786 -- 0x20000000 = 536870912 = Column is encrypted without salt
787 -- This is necessary when users do not specify an
788 -- encryption_password and the data is written to the dumpfile
789 -- in clear text although the col properity retains the
790 -- encrypt property.
791 PROCEDURE get_dpstrm_md (
792 schema IN VARCHAR2,
793 name IN VARCHAR2,
794 mdversion IN VARCHAR2 DEFAULT 'COMPATIBLE',
795 dpapiversion IN NUMBER DEFAULT 3,
796 doc IN OUT NOCOPY CLOB,
797 network_link IN VARCHAR2 DEFAULT NULL,
798 force_lob_be IN BOOLEAN DEFAULT FALSE,
799 force_no_encrypt IN BOOLEAN DEFAULT FALSE);
800
801 -- GET_VAT_TABLE_NAME
802 -- PARAMETERS:
803 -- schema - the view schema
804 -- name - the view name
805 -- network_link - The name of a database link to the database
806 -- whose data is to be retrieved. If NULL (default), metadata
807 -- is retrieved from the database on which the caller is running.
808 -- RETURNS
809 -- table name
810
811 FUNCTION get_vat_table_name (
812 schema IN VARCHAR2,
813 name IN VARCHAR2,
814 network_link IN VARCHAR2 DEFAULT NULL )
815 RETURN VARCHAR2;
816
817 -- SET_VAT_TABLE_NAME
818 -- PARAMETERS:
819 -- schema - the view schema
820 -- vname - the view name
821 -- tname - the template table name
822 -- network_link - The name of a database link to the database
823 -- whose data is to be retrieved. If NULL (default), metadata
824 -- is retrieved from the database on which the caller is running.
825
826 PROCEDURE set_vat_table_name (
827 schema IN VARCHAR2,
828 vname IN VARCHAR2,
829 tname IN VARCHAR2,
830 network_link IN VARCHAR2 DEFAULT NULL );
831
832 -- SET_DEBUG: Set the internal debug switch.
833 -- PARAMETERS:
834 -- on_off - new switch state.
835 -- arg2 - unused argument to force the overloading of
836 -- this procedure (i.e., overloaded version of this
837 -- routine will match the common datapump interface.
838
839
840 PROCEDURE set_debug(
841 on_off IN BOOLEAN,
842 arg2 IN BOOLEAN DEFAULT TRUE);
843
844 -- SET_DEBUG: Enable Metadata tracing.
845 -- PARAMETERS:
846 -- debug_flags - trace flag bitvector (see prvtkupc.sql for bit defs).
847 PROCEDURE set_debug(
848 debug_flags IN BINARY_INTEGER);
849
850 -- NET_SET_DEBUG: Set the internal debug switch on a remote node.
851 -- This function is called by the local server and runs on the
852 -- remote server.
853 -- PARAMETERS:
854 -- on_off - new switch state: 0 = OFF, non-0 = ON.
855
856 PROCEDURE net_set_debug(
857 on_off IN NUMBER);
858
859 -- FREE_CONTEXT_ENTRY: free the entry in context_list corresponding to 'ind'
860 -- Should only be called by pkg. dbms_metadata_int.
861 -- PARAMETERS:
862 -- ind - index of entry to free
863
864 PROCEDURE free_context_entry (
865 ind IN NUMBER );
866
867
868 -- FETCH_OBJNUMS: Table function to return object numbers
869 -- PARAMETERS:
870 -- handle - handle returned from open
871 -- table_type - one of 'T' (return objnums for base tables),
872 -- 'N' (for nested tables), 'X' (for nested tables
873 -- that are part of OR storage for XMLType)
874
875 FUNCTION FETCH_OBJNUMS (
876 handle IN NUMBER )
877 RETURN sys.ku$_ObjNumSet pipelined;
878
879 FUNCTION FETCH_OBJNUMS
880 RETURN sys.ku$_ObjNumSet pipelined;
881
882 FUNCTION FETCH_OBJNUMS (
883 table_type IN VARCHAR2 )
884 RETURN sys.ku$_ObjNumSet pipelined;
885
886 -- FETCH_VAT_OBJNUMS: Table function to return object numbers
887 -- of generated template tables for views_as_tables.
888
889 FUNCTION FETCH_VAT_OBJNUMS
890 RETURN sys.ku$_ObjNumSet pipelined;
891
892 -- FETCH_OBJNUMS_NAMES: Table function to return object numbers and names
893 -- IMPLICIT PARAMETER: <current handle>
894
895 FUNCTION FETCH_OBJNUMS_NAMES
896 RETURN sys.ku$_ObjNumNamSet pipelined;
897
898 -- FETCH_SORTED_OBJNUMS: Table function to return nested table of
899 -- obj#-order pairs
900 -- PARAMETERS:
901 -- handle - handle returned from open
902
903 FUNCTION FETCH_SORTED_OBJNUMS (
904 handle IN NUMBER )
905 RETURN sys.ku$_ObjNumPairList;
906
907
908 -- GET_DOMIDX_METADATA: Get PLSQL code from the ODCIIndexGetMetadata
909 -- method of a domain index's implementation type.
910 -- PARAMETERS:
911 -- index_name - name of the domain index
912 -- index_schema - schema of the domain index
913 -- type_name - name of the index's implementation type
914 -- type_schema - schema of the index's implementation type
915 -- ts_num - tablespace where index resides
916 -- may be 1 of several, but closure should assure
917 -- all tablespaces are transprotable (or not)
918 -- itinter_version - Interface version of the index's implementation type
919 -- flags - flags
920 -- RETURNS: Collection of VARCHAR2 containing a PL/SQL block
921 -- that creates the index metadata.
922
923 FUNCTION get_domidx_metadata(
924 index_name IN VARCHAR2,
925 index_schema IN VARCHAR2,
926 type_name IN VARCHAR2,
927 type_schema IN VARCHAR2,
928 ts_num IN NUMBER,
929 itinter_version IN NUMBER,
930 flags IN NUMBER)
931 RETURN sys.ku$_procobj_lines;
932
933 -- OKTOEXP_2NDARY_TABLE: Should a secondary object of a domain index
934 -- be exported?
935 -- PARAMETERS:
936 -- tab_obj_num - object number of the secondary table
937 -- RETURNS: TRUE = yes, export it
938
939 FUNCTION oktoexp_2ndary_table (
940 tab_obj_num IN NUMBER)
941 RETURN PLS_INTEGER;
942
943 -- PATCH_TYPEID: For transportable import, modify a type's typeid.
944 -- PARAMETERS:
945 -- schema - the type's schema
946 -- name - the type's name
947 -- typeid - the type's typeid
948 -- hashcode - the type's hashcode
949
950 PROCEDURE patch_typeid (
951 schema IN VARCHAR2,
952 name IN VARCHAR2,
953 typeid IN VARCHAR2,
954 hashcode IN VARCHAR2);
955
956 -- CHECK_TYPE: For transportable import, check a type's defintion and
957 -- typeid for a match against the one from the export source.
958 -- PARAMS:
959 -- schema - schema of type
960 -- type_name - type name
961 -- version - internal stored verson of type
962 -- hashcode - hashcode of the type defn
963 -- typeid - subtype typeid ('' if no subtypes)
964 -- RETURNS: Nothing, returns if the hashcode and version match. Raises an
965 -- nnn exception if the type does not exist in the db or if the
966 -- type exists but the hash code and/or the version number does
967 -- not match.
968 --
969 PROCEDURE check_type (schema IN VARCHAR2,
970 type_name IN VARCHAR2,
971 version IN VARCHAR2,
972 hashcode IN VARCHAR2,
973 typeid IN VARCHAR2);
974
975
976 -- GET_HASHCODE: Upgrade from 817 corrupts the hashcode in type$,
977 -- so we have to get it by calling kotgHashCode.
978 -- This function calls utl_cxml.getHashCode which calls into kux.c.
979 -- PARAMS:
980 -- schema - type schema
981 -- typename - type name
982 -- RETURNS:
983 -- hashcode - returned hashcode
984
985 FUNCTION get_hashcode (schema IN VARCHAR2,
986 typename IN VARCHAR2) RETURN RAW;
987
988
989 -- GET_SYSPRIVS
990 -- Get the export string from call grant_sysprivs_exp
991 -- and audit_sysprivs_exp function of a package in exppkgobj$
992 -- PARAMETERS:
993 -- package -- package name
994 -- pkg_schema -- schema of package
995 -- function -- function name(audit_sysprivs_exp or grant_sysprivs_exp)
996 -- RETURNS: system_info export string
997
998 FUNCTION get_sysprivs(
999 package IN VARCHAR2,
1000 pkg_schema IN VARCHAR2,
1001 function IN VARCHAR2)
1002 RETURN sys.ku$_procobj_lines;
1003
1004 -----------------------------------------------------------------------
1005 -- GET_PROCOBJ
1006 -- Get the export string from call create_exp or audit_exp or grant_exp
1007 -- function of package in exppkobj$
1008 -- PARAMETERS:
1009 -- package -- package name
1010 -- pkg_schema -- schema of package
1011 -- function -- function name (create_exp or audit_exp or grant_exp)
1012 -- objid -- object number
1013 -- isdba -- 1: is dba
1014 -- RETURNS: create/audit/grant export string
1015
1016 FUNCTION get_procobj(
1017 package IN VARCHAR2,
1018 pkg_schema IN VARCHAR2,
1019 function IN VARCHAR2,
1020 objid IN NUMBER,
1021 isdba IN PLS_INTEGER
1022 )
1023 RETURN sys.ku$_procobj_lines;
1024 -----------------------------------------------------------------------
1025 -- GET_PROCOBJ_GRANT
1026 -- Get the export string from call grant_exp function of package in exppkobj$
1027 -- PARAMETERS:
1028 -- package -- package name
1029 -- pkg_schema -- schema of package
1030 -- function -- function name (grant_exp)
1031 -- objid -- object number
1032 -- isdba -- 1: is dba
1033 -- RETURNS: create/audit/grant export string
1034
1035 FUNCTION get_procobj_grant(
1036 package IN VARCHAR2,
1037 pkg_schema IN VARCHAR2,
1038 function IN VARCHAR2,
1039 objid IN NUMBER,
1040 isdba IN PLS_INTEGER
1041 )
1042 RETURN sys.ku$_procobj_lines;
1043
1044 -----------------------------------------------------------------------
1045 -- GET_ACTION_INSTANCE
1046 -- Get the export string from call instance_info_exp and
1047 -- instance_extented_info_exp function of package in exppkgact$
1048 -- PARAMETERS:
1049 -- package -- package name
1050 -- pkg_schema -- schema of package
1051 -- function -- function name (instance_info_exp
1052 -- or instance_extended_info_exp)
1053 -- name -- instance name
1054 -- schema -- instance schema
1055 -- namespace --
1056 -- objtype --
1057 -- prepost -- 0: pre-action, 1:post_action
1058 -- isdba -- 1: is dba
1059 -- RETURNS:
1060 -- instance info export_string
1061
1062 FUNCTION get_action_instance(
1063 package IN VARCHAR2,
1064 pkg_schema IN VARCHAR2,
1065 function IN VARCHAR2,
1066 name IN VARCHAR2,
1067 schema IN VARCHAR2,
1068 namespace IN number,
1069 objtype IN number,
1070 prepost IN number,
1071 isdba IN number)
1072 RETURN sys.ku$_procobj_lines;
1073
1074 -----------------------------------------------------------------------
1075 -- GET_ACTION_SYS
1076 -- Get the export string from call system_info_exp function of package
1077 -- in exppkgact$
1078 -- PARAMETERS:
1079 -- package -- package name
1080 -- pkg_schema -- schema of package
1081 -- function -- function name (system_info_exp)
1082 -- prepost -- 0 :pre-action, 1: post-action
1083 -- RETURNS:
1084 -- system info export_string
1085
1086 FUNCTION get_action_sys(
1087 package IN VARCHAR2,
1088 pkg_schema IN VARCHAR2,
1089 function IN VARCHAR2,
1090 prepost IN NUMBER)
1091 RETURN sys.ku$_procobj_lines;
1092
1093 -----------------------------------------------------------------------
1094 -- GET_ACTION_SCHEMA
1095 -- Get the export string from call schema_info_exp
1096 -- function of package in exppkgact$
1097 -- PARAMETERS:
1098 -- package -- package name
1099 -- pkg_schema -- schema of package
1100 -- function -- function name (schema_info_exp)
1101 -- schema -- each user
1102 -- prepost -- 0 :pre-action, 1: post-action
1103 -- isdba -- 1: is dba
1104 -- RETURNS:
1105 -- schema info export_string
1106
1107 FUNCTION get_action_schema(
1108 package IN VARCHAR2,
1109 pkg_schema IN VARCHAR2,
1110 function IN VARCHAR2,
1111 schema IN VARCHAR2,
1112 prepost IN NUMBER,
1113 isdba IN NUMBER)
1114 RETURN sys.ku$_procobj_lines;
1115
1116 -----------------------------------------------------------------------
1117 -- GET_PLUGTS_BLK : Get PLSQL code from dbms_plugts.selectBlock and getLine.
1118 -- This generates the pre-import and post-import anonymous blocks
1119 -- for transportable.
1120 -- PARAMETERS:
1121 -- blockID - 0 = pre-import; non-0 = post-import
1122
1123 FUNCTION get_plugts_blk (
1124 blockID IN NUMBER )
1125 RETURN sys.ku$_procobj_lines;
1126
1127 -- GET_JAVA_METADATA: Return java class, source, resource info
1128 -- PARAMETERS:
1129 -- java_name - java class or resource or source name
1130 -- schema_name - schema name
1131 -- type_num - object type
1132 -- RETURNS: nested table of java info
1133
1134 FUNCTION get_java_metadata(
1135 java_name IN VARCHAR2,
1136 java_schema IN VARCHAR2,
1137 type_num IN NUMBER)
1138 RETURN sys.ku$_java_t;
1139
1140
1141 -- GET_PREPOST_TABLE_ACT
1142 -- Get the export string for pre-table action
1143 -- from call sys.dbms_export_extension.pre_table
1144 -- Get the export string for post-table action
1145 -- from call sys.dbms_export_extension.post_tables
1146 -- PARAMETERS:
1147 -- prepost -- 1 is pre-table action, 2 is post-table action
1148 -- schema -- schema name
1149 -- tname -- table name
1150 -- RETURNS:
1151 -- table pre/post table action string
1152
1153 FUNCTION get_prepost_table_act(
1154 prepost IN NUMBER,
1155 schema IN VARCHAR2,
1156 tname IN VARCHAR2)
1157 RETURN sys.ku$_taction_list_t;
1158
1159 -- GET_CANONICAL_VSN: convert the user's VERSION param to a string
1160 -- in the format vv.vv.vv.vv.vv, e.g., '08.01.03.00.00'
1161 -- PARAMETERS:
1162 -- version - The version from DBMS_METADATA.OPEN.
1163 -- Values can be 'COMPATIBLE' (default), 'LATEST' or a specific
1164 -- version number.
1165
1166 FUNCTION get_canonical_vsn(version IN VARCHAR2)
1167 RETURN VARCHAR2;
1168
1169 ---------------------------------------------------------------------
1170 -- CONVERT_TO_CANONICAL: Convert string to canonical form
1171 -- vv.vv.vv.vv.vv, e.g., '08.01.03.00.00'
1172 -- PARAMETERS:
1173 -- version - version string (e.g., 10.2.0.2)
1174
1175 FUNCTION convert_to_canonical(version IN VARCHAR2)
1176 RETURN VARCHAR2;
1177
1178 ---------------------------------------------------------------------
1179 -- GET_INDEX_INTCOL - Get intcol# in table of column on which index is
1180 -- defined (need special handling for xmltype cols)
1181 -- PARAMETERS:
1182 -- obj_num - base table object #
1183 -- intcol_num - intcol# from icol$
1184 --
1185 -- This is a wrapper function around dbms_metadata_util.get_index_intcol.
1186
1187
1188 FUNCTION get_index_intcol(obj_num IN NUMBER,
1189 intcol_num in NUMBER)
1190 RETURN NUMBER;
1191
1192 ---------------------------------------------------------------------
1193 -- OPENW: Specifies the type of object whose metadata is to be submitted.
1194 -- PARAMETERS:
1195 -- object_type - Identifies the type of objects to be submitted; e.g.,
1196 -- TABLE, INDEX, etc. May not be a heterogeneous
1197 -- object type.
1198 -- version - The version of the objects' DDL to be created.
1199 -- Values can be 'COMPATIBLE' (default), 'LATEST' or a specific
1200 -- version number.
1201 -- model - The view of the metadata, such as Oracle proprietary,
1202 -- ANSI99, etc. Currently only 'ORACLE' is supported.
1203 --
1204 -- RETURNS:
1205 -- A handle to be used in subsequent calls to ADD_TRANSFORM, CONVERT,
1206 -- PUT and CLOSE.
1207 -- EXCEPTIONS:
1208 -- INVALID_ARGVAL - a NULL or invalid value was supplied for an input
1209 -- parameter.
1210
1211 FUNCTION openw (
1212 object_type IN VARCHAR2,
1213 version IN VARCHAR2 DEFAULT 'COMPATIBLE',
1214 model IN VARCHAR2 DEFAULT 'ORACLE')
1215 RETURN NUMBER;
1216
1217
1218 -- CONVERT: Convert an input XML document into creation DDL.
1219 -- More than one DDL statement may be returned.
1220 -- RETURNS: Metadata for the objects as one or more DDL statements
1221 -- PARAMETERS: handle - Context handle from previous OPENW call.
1222 -- document - XML document containing object metadata of
1223 -- the type of the OPENW handle.
1224 -- EXCEPTIONS: Throws an exception if DDL transform was not added.
1225
1226 FUNCTION convert (
1227 handle IN NUMBER,
1228 document IN sys.XMLType)
1229 RETURN sys.ku$_multi_ddls;
1230
1231 FUNCTION convert (
1232 handle IN NUMBER,
1233 document IN CLOB)
1234 RETURN sys.ku$_multi_ddls;
1235
1236
1237 -- CONVERT: This is an alternate, higher-performing but less flexible form
1238 -- of CONVERT that returns only a single (but multi-object) CLOB
1239 -- with a collection providing offsets into this CLOB to locate
1240 -- each individual DDL. Parse items per DDL are NOT returned with
1241 -- this version.
1242 -- RETURNS: CLOB containing multiple DDL statements.
1243 -- PARAMETERS: handle - Context handle from previous OPENW call.
1244 -- document - CLOB containing the XML to be converted to DDL
1245 -- offsets - Collection of pointers/lengths into returned CLOB
1246 -- EXCEPTIONS: Throws an exception if DDL transform was not added.
1247
1248 FUNCTION convert (
1249 handle IN NUMBER,
1250 document IN CLOB,
1251 offsets OUT NOCOPY multiobjects)
1252 RETURN CLOB;
1253
1254
1255 -- CONVERT: Procedure variants to convert an input XML document as
1256 -- specified by user transforms.
1257 -- PARAMETERS: handle - Context handle from previous OPENW call.
1258 -- document - XML document containing object metadata of
1259 -- the type of the OPENW handle.
1260 -- result - the converted document.
1261 -- EXCEPTIONS: Throws an exception if no transform was added.
1262
1263 PROCEDURE convert (
1264 handle IN NUMBER,
1265 document IN sys.XMLType,
1266 result IN OUT NOCOPY CLOB );
1267
1268 PROCEDURE convert (
1269 handle IN NUMBER,
1270 document IN CLOB,
1271 result IN OUT NOCOPY CLOB );
1272
1273
1274 -- PUT: Convert an input XML document into creation DDL
1275 -- and submit the resultant DDL to the database. Two forms are
1276 -- provided: One that accepts XML as a CLOB, the other as XMLType.
1277 -- RETURNS: A BOOLEAN indicating if something went wrong. If TRUE,
1278 -- everything went OK and results doesn't necessarily have to be
1279 -- parsed.
1280 -- PARAMETERS: handle - Context handle from previous OPENW call.
1281 -- document - XML document containing object metadata of
1282 -- the type of the OPENW handle.
1283 -- flags - Various flags controlling operation:
1284 -- PUT_RAISE_EXCEPTION = raise exception, do return results
1285 -- results - A ku$_SubmitResults object passed by reference that
1286 -- contains detailed results of the operation. Each
1287 -- object's DDL text, parsed items and associated
1288 -- error msgs are included.
1289 -- EXCEPTIONS: Throws an exception if DDL transform was not added or an
1290 -- error occurs during XSL transformation.
1291
1292 FUNCTION put (
1293 handle IN NUMBER,
1294 document IN sys.XMLType,
1295 flags IN NUMBER,
1296 results IN OUT NOCOPY sys.ku$_SubmitResults)
1297 RETURN BOOLEAN;
1298
1299 FUNCTION put (
1300 handle IN NUMBER,
1301 document IN CLOB,
1302 flags IN NUMBER,
1303 results IN OUT NOCOPY sys.ku$_SubmitResults)
1304 RETURN BOOLEAN;
1305
1306 -- PUT: Procedure variant of the above. The key difference
1307 -- is the exception handling.
1308 -- EXCEPTIONS: Throws an exception if DDL transform was not added or an
1309 -- error occurs during XSL transformation. Also raises
1310 -- any exceptions from SQL execution.
1311
1312 PROCEDURE put (
1313 handle IN NUMBER,
1314 document IN CLOB);
1315
1316 FUNCTION check_match_template (
1317 pobjno IN NUMBER,
1318 spcnt IN NUMBER)
1319 RETURN NUMBER;
1320
1321 FUNCTION check_match_template_par (
1322 pobjno IN NUMBER,
1323 spcnt IN NUMBER)
1324 RETURN NUMBER;
1325
1326 FUNCTION check_match_template_lob (
1327 pobjno IN NUMBER,
1328 spcnt IN NUMBER)
1329 RETURN NUMBER;
1330
1331 -----------------------------------------------------------------------
1332 -- GET_EDITION:
1333 -- This function returns the edition of interest for the current MDAPI
1334 -- function. (this is either specified as the 'edition' filter, or
1335 -- the session current edition.
1336 -- RETURNS:
1337 -- VARCHAR2 containing edition name.
1338 -- PARAMETERS:
1339 -- none
1340 -- EXCEPTIONS: none
1341
1342 FUNCTION GET_EDITION RETURN VARCHAR2;
1343
1344 -- GET_EDITION_ID:
1345 -- This function returns the edition of interest for the current MDAPI
1346 -- function. (this is either specified as the 'edition' filter, or
1347 -- the session current edition.
1348 -- RETURNS:
1349 -- NUMBER containing edition ID.
1350 -- PARAMETERS:
1351 -- none
1352 -- EXCEPTIONS: none
1353
1354 FUNCTION GET_EDITION_ID RETURN NUMBER;
1355
1356 -- GET_VERSION:
1357 -- This function returns the version of interest for the current MDAPI
1358 -- context. Comes from the version parameter in open.
1359 -- RETURNS:
1360 -- NUMBER containing version.
1361 -- PARAMETERS:
1362 -- none
1363 -- EXCEPTIONS: none
1364
1365 FUNCTION GET_VERSION
1366 RETURN VARCHAR2;
1367
1368 -- GET_STAT_COLNAME
1369 -- This function returns a column name for restoring statistics.
1370 -- RETURNS:
1371 -- VARCHAR2 containing the column name
1372 -- PARAMETERS:
1373 -- OWNER_NAME - schema name that owns the table
1374 -- TABLENAME - table name where column exists
1375 -- DEFAULT_VAL - value or null from col$.default$
1376 -- ATTR_COLNAME - value or null from attrcol$.name
1377 -- NESTED_TABLE - 1 if nested table, 0 otherwise
1378 -- EXCEPTIONS: none
1379 --
1380 -- RETURNS: - COLUMN NAME
1381 FUNCTION GET_STAT_COLNAME(
1382 OWNER_NAME in varchar2,
1383 TABLENAME in varchar2,
1384 DEFAULT_VAL in long,
1385 ATTR_COLNAME in varchar2,
1386 NESTED_TABLE in number)
1387 RETURN VARCHAR2;
1388
1389 -- GET_STAT_INDNAME
1390 -- This procedure returns an index_owner and index name for restoring
1391 -- statistics.
1392 -- PARAMETERS:
1393 -- TABLE_OWNER - schema name that owns the table
1394 -- TABLE_NAME - name of table that index is on
1395 -- COLNAME_LIST - varray of columns that index is on
1396 -- COL_COUNT - number of columns that index is on
1397 -- RETURNS:
1398 -- IND_OWNER - owner of index
1399 -- IND_NAME - name of index
1400 -- EXCEPTIONS: none
1401 PROCEDURE GET_STAT_INDNAME(
1402 TABLE_OWNER IN VARCHAR2,
1403 TABLE_NAME IN VARCHAR2,
1404 COLNAMES IN T_VAR_COLL,
1405 COL_COUNT IN NUMBER,
1406 IND_OWNER OUT VARCHAR2,
1407 IND_NAME OUT VARCHAR2);
1408
1409 -- The following 3 PARSE_ functions are jackets around calls to
1410 -- similar routines in dbms_metadata_util. If the user has
1411 -- set the PARSE_EXPRESSIONS parameter TRUE, they call the
1412 -- appropriate functions in dbms_metadata_util; otherwise they return NULL.
1413
1414 -- PARSE_CONDITION: Parse a check constraint condition on a table
1415 -- and return it as XML
1416 -- PARAMETERS:
1417 -- schema - schema
1418 -- tab - table name
1419 -- length - length of the constraint
1420 -- row - rowid of the row in CDEF$
1421 -- RETURNS: XMLType containing parsed condition as XML
1422 -- if length is not NULL
1423 -- otherwise NULL
1424
1425 FUNCTION parse_condition(
1426 schema IN VARCHAR2,
1427 tab IN VARCHAR2,
1428 length IN NUMBER,
1429 row IN ROWID)
1430 RETURN SYS.XMLTYPE;
1431
1432 -- PARSE_DEFAULT: Parse the default value of a virtual column
1433 -- (which contains an arithmetic expression for a functional index)
1434 -- and return it as XML
1435 -- PARAMETERS:
1436 -- schema - schema
1437 -- tab - table name
1438 -- length - length of the default
1439 -- row - rowid of the row in COL$
1440 -- RETURNS: XMLType containing parsed expression as XML
1441 -- if length is not NULL
1442 -- otherwise NULL
1443
1444 FUNCTION parse_default(
1445 schema IN VARCHAR2,
1446 tab IN VARCHAR2,
1447 length IN NUMBER,
1448 row IN ROWID)
1449 RETURN SYS.XMLTYPE;
1450
1451 -- PARSE_QUERY: Parse a query stored in a long column (e.g., view query).
1452 -- and return it as XML
1453 -- PARAMETERS:
1454 -- schema - schema
1455 -- length - length of the LONG
1456 -- tab - table name
1457 -- col - column name
1458 -- row - rowid of the row
1459 -- read_only - non-0 = query has 'with read only'
1460 -- check_option - non-0 = query has 'with check option'
1461 -- RETURNS: XMLType containing parsed query as XML
1462 -- if length is not NULL
1463 -- otherwise NULL
1464
1465 FUNCTION parse_query(
1466 schema IN VARCHAR2,
1467 length IN NUMBER,
1468 tab IN VARCHAR2,
1469 col IN VARCHAR2,
1470 row IN ROWID,
1471 read_only IN NUMBER DEFAULT 0,
1472 check_option IN NUMBER DEFAULT 0)
1473 RETURN SYS.XMLTYPE;
1474
1475 -- GET_CHECK_CONSTRAINT_NAME - Return the constraint name given the
1476 -- condition. (Useful if name is system-generated.)
1477 -- PARAMETERS:
1478 -- object_type - object type of base object
1479 -- schema - Schema containing the base object.
1480 -- name - Name of the base object.
1481 -- condition - condition (parsed or unparsed)
1482 -- parsed_condition- boolean; TRUE = condition is parsed
1483 -- RETURNS: Constraint name or NULL if not found
1484
1485 FUNCTION get_check_constraint_name(
1486 object_type IN VARCHAR2,
1487 schema IN VARCHAR2,
1488 name IN VARCHAR2,
1489 condition IN CLOB,
1490 parsed_condition IN BOOLEAN DEFAULT FALSE)
1491 RETURN VARCHAR2;
1492
1493 -- OPEN_GET_FK_CONSTRAINT_NAME - This and the following 2 apis return
1494 -- the name of a foreign key constraint given its
1495 -- definition. (Useful if name is system-generated.)
1496 -- PARAMETERS:
1497 -- object_type - object type of base object
1498 -- schema - Schema containing the base object.
1499 -- name - Name of the base object.
1500 -- ref_schema - Schema containing the referenced object.
1501 -- ref_name - Name of the referenced object.
1502 -- RETURNS: Handle to be used in subsequent calls.
1503
1504 FUNCTION open_get_fk_constraint_name(
1505 object_type IN VARCHAR2,
1506 schema IN VARCHAR2,
1507 name IN VARCHAR2,
1508 ref_schema IN VARCHAR2,
1509 ref_name IN VARCHAR2)
1510 RETURN NUMBER;
1511
1512 -- SET_FK_CONSTRAINT_COL_PAIR - After calling OPEN_GET_FK_CONSTRAINT_NAME,
1513 -- the program calls this for each pair of corresponding columns.
1514 -- The order of calls defines the order of columns in the constraint.
1515 -- PARAMETERS:
1516 -- handle - handle returned by OPEN_GET_FK_CONSTRAINT_NAME
1517 -- src_col - name of column in base table
1518 -- tgt_col - name of corresponding column in ref table
1519
1520 PROCEDURE set_fk_constraint_col_pair(
1521 handle IN NUMBER,
1522 src_col IN VARCHAR2,
1523 tgt_col IN VARCHAR2);
1524
1525
1526 -- GET_FK_CONSTRAINT_NAME
1527 -- PARAMETERS:
1528 -- handle - handle returned by OPEN_GET_FK_CONSTRAINT_NAME
1529 -- RETURNS: Constraint name or NULL if not found
1530
1531 FUNCTION get_fk_constraint_name(
1532 handle IN NUMBER)
1533 RETURN VARCHAR2;
1534
1535
1536 ---------------------------------------------------------------------
1537 -- IS_ATTR_VALID_ON_10 -
1538 --
1539 -- PARAMETERS:
1540 -- obj_num - base table object #
1541 -- intcol_num - intcol# from icol$
1542 --
1543 -- This is a wrapper function around dbms_metadata_int.is_attr_valid_on_10.
1544
1545
1546 FUNCTION is_attr_valid_on_10(obj_num IN NUMBER,
1547 intcol_num in NUMBER)
1548 RETURN NUMBER;
1549
1550 ---------------------------------------------------------------------
1551 -- IS_XDB_TRANS - - test for XDB/transportable
1552 --
1553 -- PARAMETERS: none
1554 --
1555 -- return 1 is XDB repository is in a tablespace which
1556 -- will be moved via TTS
1557
1558 FUNCTION is_xdb_trans
1559 RETURN NUMBER;
1560
1561 ---------------------------------------------------------------------
1562 -- IN_TSNUM - return 1 if TS# is in the selected set
1563 --
1564 -- PARAMETERS:
1565 -- TS_SET - 1 for transportable TS
1566 -- 2 for early TS
1567 -- TS_NUM - tablespace number to test
1568 --
1569 -- return 1 if TS# is in the selected set
1570
1571
1572 FUNCTION in_tsnum (
1573 TS_SET IN NUMBER,
1574 TS_NUM IN NUMBER )
1575 RETURN NUMBER DETERMINISTIC;
1576
1577 ---------------------------------------------------------------------
1578 -- IN_TSNUM_2 - return 1 if OBJ# is in the selected set
1579 --
1580 -- PARAMETERS:
1581 -- TS_SET - 1 for transportable TS
1582 -- 2 for early TS
1583 -- OBJ_NUM - object to test
1584 -- TS_NUM - tab$.ts# (not valid if table is partitioned)
1585 -- PROPERTY - low-order bits of tab$.property
1586 --
1587 -- return 1 if object is in the selected set
1588
1589 FUNCTION in_tsnum_2 (
1590 TS_SET IN NUMBER,
1591 OBJ_NUM IN NUMBER,
1592 TS_NUM IN NUMBER,
1593 PROPERTY IN NUMBER)
1594 RETURN NUMBER DETERMINISTIC;
1595
1596 ---------------------------------------------------------------------
1597 -- GET_PARTN - "relative fragment number" for the partition.
1598 --
1599 -- PARAMETERS:
1600 -- PARTYPE - 1 - tabpart
1601 -- 2 - tabcompart
1602 -- 3 - tabsubpart
1603 -- 4 - indpart
1604 -- 5 - indcompart
1605 -- 6 - indsubpart
1606 -- 7 - lobfrag
1607 -- 8 - lobcomppart
1608 -- BOBJ_NUM - object number of which this is a partition
1609 -- PART_NUM - partition number (as stored in dictionary)
1610 --
1611 -- return "relative fragment number" for the partition.
1612
1613
1614 FUNCTION get_partn (
1615 PARTYPE IN NUMBER,
1616 BOBJ_NUM IN NUMBER,
1617 PART_NUM IN NUMBER )
1618 RETURN NUMBER DETERMINISTIC;
1619
1620 ---------------------------------------------------------------------
1621 -- GET_INDPART_TS - get a ts# for an index (sub)partition
1622 -- (used by ku$_index_view
1623 -- PARAMETERS:
1624 -- obj_num - obj# for table
1625
1626 FUNCTION get_indpart_ts (
1627 OBJ_NUM IN NUMBER )
1628 RETURN NUMBER;
1629
1630 --------------------------------------------------------------------
1631 -- TRANSFORM_STRM - Transfrom stream metadata
1632 --
1633 -- PARAMETERS :
1634 -- indoc - Input stream metadata
1635 -- outdoc - Transformed stream metadata
1636 -- mdversion - Metadata version
1637
1638 PROCEDURE transform_strm (
1639 indoc IN CLOB,
1640 outdoc IN OUT NOCOPY CLOB,
1641 mdversion IN VARCHAR2 DEFAULT 'COMPATIBLE');
1642
1643 END DBMS_METADATA;