home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / programming / oracle7 7.2 / DB / UTIL72 / CATREPAD.SQL < prev    next >
Encoding:
Text File  |  1995-05-09  |  59.0 KB  |  1,816 lines

  1. rem $Header: catrepad.sql 7020200.1 95/02/15 18:32:50 cli Generic<base> $ 
  2. rem 
  3. Rem  Copyright (c) 1991 by Oracle Corporation 
  4. Rem    NAME
  5. Rem      catrepad.sql - Create the views and tables required for 
  6. Rem                     Symmetric Replication in Server Manager
  7. Rem    DESCRIPTION
  8. Rem      
  9. Rem    RETURNS
  10. Rem 
  11. Rem    NOTES
  12. Rem      Connects as internal (no password)
  13. Rem    MODIFIED   (MM/DD/YY)
  14. Rem     echeng     01/05/95 -  Branch_for_patch
  15. Rem       asirna   12/14/94 - fix problem in view dba_admindeftran. add distinc
  16. Rem       asirna   12/05/94 - drop table sys.defcallargs before creating it
  17. Rem       hasun    11/09/94 - merge
  18. Rem       hasun    11/06/94 - alter dbme_defer_print to use package variables
  19. Rem       hasun    11/03/94 - merge
  20. Rem       hasun    11/03/94 - fix *_admin* views
  21. Rem       hasun    11/03/94 - change *_admindeftran to show all destination
  22. Rem       hasun    11/02/94 - change *_adminresolution to show all tables
  23. Rem       hasun    10/27/94 - fix  adminschema views
  24. Rem       hasun    10/20/94 - Creation
  25.  
  26. --------------------------------------------------------------------------
  27. --- Create the views used by the object lists in the Replication Drawer of
  28. --- Server Manager
  29. --------------------------------------------------------------------------
  30. --- (1)
  31. ---
  32. create or replace view DBA_ADMINSCHEMAS
  33.   (SNAME, SITE_TYPE, STATUS, SCOMMENT, OBJ_CNT)
  34. as
  35. select distinct -- masters and masterdefs
  36.   r.sname,
  37.   DECODE(s.masterdef, 'Y', 'Master Def', 'Master'),
  38.   r.status,
  39.   r.schema_comment,
  40.   count(o.oname)  
  41. from
  42.   dba_repcat r, 
  43.   dba_repschema s,
  44.   dba_repobject o
  45. where
  46.   (r.master = 'Y') and
  47.   (r.sname = s.sname and
  48.     s.dblink in (select global_name from global_name)) and
  49.   (r.sname = o.sname)
  50. group by r.sname, s.masterdef, r.status,  r.schema_comment
  51. union
  52. select distinct
  53.   r.sname,
  54.   'Snapshot',
  55.   r.status,
  56.   r.schema_comment,
  57.   count(o.oname)
  58. from 
  59.   dba_repcat r,
  60.   dba_repobject o
  61. where    
  62.   (r.master = 'N') and
  63.   (r.sname = o.sname)
  64. group by  r.sname, r.status, r.schema_comment
  65. /
  66. comment on table DBA_ADMINSCHEMAS is
  67. 'Information about all replicated schemas'
  68. /
  69. comment on column DBA_ADMINSCHEMAS.SNAME is
  70. 'Name of the replicated schema'
  71. /
  72. comment on column DBA_ADMINSCHEMAS.SITE_TYPE is
  73. 'Is the site a masterdef, master, or snapshot site for the replicated schema'
  74. /
  75. comment on column DBA_ADMINSCHEMAS.STATUS is
  76. 'If the site is a master, the master''s status'
  77. /
  78. comment on column DBA_ADMINSCHEMAS.SCOMMENT is
  79. 'Description of the replicated schema'
  80. /
  81. comment on column DBA_ADMINSCHEMAS.OBJ_CNT is
  82. 'Number of replicated objects owned by the replicated schema'
  83. /
  84. create or replace view ALL_ADMINSCHEMAS
  85.   (SNAME, SITE_TYPE, STATUS, SCOMMENT, OBJ_CNT)
  86. as
  87. select distinct -- masters and masterdefs
  88.   r.sname,
  89.   DECODE(s.masterdef, 'Y', 'Master Def', 'Master'),
  90.   r.status,
  91.   r.schema_comment,
  92.   count(o.oname)  
  93. from
  94.   dba_repcat r, 
  95.   dba_repschema s,
  96.   dba_repobject o
  97. where
  98.   (r.master = 'Y') and
  99.   (r.sname = s.sname and
  100.     s.dblink in (select global_name from global_name)) and
  101.   (r.sname = o.sname)
  102. group by r.sname, s.masterdef, r.status,  r.schema_comment
  103. union
  104. select distinct
  105.   r.sname,
  106.   'Snapshot',
  107.   r.status,
  108.   r.schema_comment,
  109.   count(o.oname)
  110. from 
  111.   dba_repcat r,
  112.   dba_repobject o
  113. where    
  114.   (r.master = 'N') and
  115.   (r.sname = o.sname)
  116. group by  r.sname, r.status, r.schema_comment
  117. /
  118. comment on table ALL_ADMINSCHEMAS is
  119. 'Information about replicated schemas'
  120. /
  121. comment on column ALL_ADMINSCHEMAS.SNAME is
  122. 'Name of the replicated schema'
  123. /
  124. comment on column ALL_ADMINSCHEMAS.SITE_TYPE is
  125. 'Is the site a masterdef, master, or snapshot site for the replicated schema'
  126. /
  127. comment on column ALL_ADMINSCHEMAS.STATUS is
  128. 'If the site is a master, the master''s status'
  129. /
  130. comment on column ALL_ADMINSCHEMAS.SCOMMENT is
  131. 'Description of the replicated schema'
  132. /
  133. comment on column ALL_ADMINSCHEMAS.OBJ_CNT is
  134. 'Count of replicated objects owned by each schema'
  135. /
  136. drop public synonym ALL_ADMINSCHEMAS
  137. /
  138. create public synonym ALL_ADMINSCHEMAS for ALL_ADMINSCHEMAS
  139. /
  140. grant select on ALL_ADMINSCHEMAS to PUBLIC with grant option
  141. /
  142. create or replace view USER_ADMINSCHEMAS
  143.   (SNAME, SITE_TYPE, STATUS, SCOMMENT, OBJ_CNT)
  144. as
  145. select distinct -- masters and masterdefs
  146.   r.sname,
  147.   DECODE(s.masterdef, 'Y', 'Master Def', 'Master'),
  148.   r.status,
  149.   r.schema_comment,
  150.   count(o.oname)  
  151. from
  152.   dba_repcat r, 
  153.   dba_repschema s,
  154.   dba_repobject o
  155. where
  156.   (r.master = 'Y') and
  157.   (r.sname = s.sname and
  158.     s.dblink in (select global_name from global_name)) and
  159.   (r.sname = o.sname)
  160. group by r.sname, s.masterdef, r.status,  r.schema_comment
  161. union
  162. select distinct
  163.   r.sname,
  164.   'Snapshot',
  165.   r.status,
  166.   r.schema_comment,
  167.   count(o.oname)
  168. from 
  169.   dba_repcat r,
  170.   dba_repobject o
  171. where    
  172.   (r.master = 'N') and
  173.   (r.sname = o.sname)
  174. group by  r.sname, r.status, r.schema_comment
  175. /
  176. comment on table USER_ADMINSCHEMAS is
  177. 'Replication information about the current user'
  178. /
  179. comment on column USER_ADMINSCHEMAS.SNAME is
  180. 'Name of the user'
  181. /
  182. comment on column USER_ADMINSCHEMAS.SITE_TYPE is
  183. 'Is the site a masterdef, master, or snapshot site for the replicated schema'
  184. /
  185. comment on column USER_ADMINSCHEMAS.STATUS is
  186. 'If site is master, the master''s status'
  187. /
  188. comment on column USER_ADMINSCHEMAS.SCOMMENT is
  189. 'User description of the replicated schema'
  190. /
  191. comment on column USER_ADMINSCHEMAS.OBJ_CNT is
  192. 'Count of replicated objects owned by the user'
  193. /
  194. drop public synonym USER_ADMINSCHEMAS
  195. /
  196. create public synonym USER_ADMINSCHEMAS for USER_ADMINSCHEMAS
  197. /
  198. grant select on USER_ADMINSCHEMAS to PUBLIC with grant option
  199. /
  200.  
  201. --- (2)
  202. ---
  203. create or replace view DBA_ADMINOBJECTS
  204.   (SNAME, ONAME, TYPE, STATUS, OCOMMENT)
  205. as
  206. select distinct
  207.   r.sname,
  208.   r.oname,
  209.   r.type,
  210.   r.status,
  211.   r.object_comment
  212. from
  213.   dba_repobject r
  214. /
  215. comment on table DBA_ADMINOBJECTS is
  216. 'Information about replicated objects'
  217. /
  218. comment on column DBA_ADMINOBJECTS.SNAME is
  219. 'Name of the object owner'
  220. /
  221. comment on column DBA_ADMINOBJECTS.ONAME is
  222. 'Name of the object'
  223. /
  224. comment on column DBA_ADMINOBJECTS.TYPE is
  225. 'Type of the object'
  226. /
  227. comment on column DBA_ADMINOBJECTS.STATUS is
  228. 'Status of the last create or alter request on the local object'
  229. /
  230. comment on column DBA_ADMINOBJECTS.OCOMMENT is
  231. 'Description of the replicated object'
  232. /
  233. create or replace view ALL_ADMINOBJECTS
  234.   (SNAME, ONAME, TYPE, STATUS, OCOMMENT)
  235. as
  236. select distinct
  237.   r.sname,
  238.   r.oname,
  239.   r.type,
  240.   r.status,
  241.   r.object_comment
  242. from
  243.   all_repobject r
  244. /
  245. comment on table ALL_ADMINOBJECTS is
  246. 'Information about replicated objects'
  247. /
  248. comment on column ALL_ADMINOBJECTS.SNAME is
  249. 'Name of the object owner'
  250. /
  251. comment on column ALL_ADMINOBJECTS.ONAME is
  252. 'Name of the object'
  253. /
  254. comment on column ALL_ADMINOBJECTS.TYPE is
  255. 'Type of the object'
  256. /
  257. comment on column ALL_ADMINOBJECTS.STATUS is
  258. 'Status of the last create or alter request on the local object'
  259. /
  260. comment on column ALL_ADMINOBJECTS.OCOMMENT is
  261. 'Description of the replicated object'
  262. /
  263. drop public synonym ALL_ADMINOBJECTS
  264. /
  265. create public synonym ALL_ADMINOBJECTS for ALL_ADMINOBJECTS
  266. /
  267. grant select on ALL_ADMINOBJECTS to PUBLIC with grant option
  268. /
  269. create or replace view USER_ADMINOBJECTS
  270.   (SNAME, ONAME, TYPE, STATUS, OCOMMENT)
  271. as
  272. select distinct
  273.   r.sname,
  274.   r.oname,
  275.   r.type,
  276.   r.status,
  277.   r.object_comment
  278. from
  279.   user_repobject r
  280. /
  281. comment on table USER_ADMINOBJECTS is
  282. 'Replication information about the current user''s objects'
  283. /
  284. comment on column USER_ADMINOBJECTS.SNAME is
  285. 'Name of the user'
  286. /
  287. comment on column USER_ADMINOBJECTS.ONAME is
  288. 'Name of the object'
  289. /
  290. comment on column USER_ADMINOBJECTS.TYPE is
  291. 'Type of the object'
  292. /
  293. comment on column USER_ADMINOBJECTS.STATUS is
  294. 'Status of the last create or alter request on the local object'
  295. /
  296. comment on column USER_ADMINOBJECTS.OCOMMENT is
  297. 'User description of the replicated object'
  298. /
  299. drop public synonym USER_ADMINOBJECTS
  300. /
  301. create public synonym USER_ADMINOBJECTS for USER_ADMINOBJECTS
  302. /
  303. grant select on USER_ADMINOBJECTS to PUBLIC with grant option
  304. /
  305.  
  306.  
  307. --- (3)
  308. ---
  309. create or replace view DBA_ADMINMASTERS
  310.   (SNAME, DBLINK, MASTERDEF, SNAPMASTER, MCOMMENT)
  311. as
  312. select distinct
  313.   r.sname,
  314.   r.dblink,
  315.   DECODE(r.masterdef, 'Y', 'Yes', 'No'),
  316.   DECODE(r.snapmaster, 'Y', 'Yes', 'No'),
  317.   r.master_comment
  318. from
  319.   dba_repschema r
  320. where
  321.   r.dblink not in (select global_name from global_name)
  322. /
  323. comment on table DBA_ADMINMASTERS is
  324. 'N-way replication information'
  325. /
  326. comment on column DBA_ADMINMASTERS.SNAME is
  327. 'Name of the replicated schema'
  328. /
  329. comment on column DBA_ADMINMASTERS.DBLINK is
  330. 'A database site replicating the schema'
  331. /
  332. comment on column DBA_ADMINMASTERS.MASTERDEF is
  333. 'Is the database the master definition site for the replicated schema'
  334. /
  335. comment on column DBA_ADMINMASTERS.SNAPMASTER is
  336. 'For a snapshot site, is the database the current refresh master'
  337. /
  338. comment on column DBA_ADMINMASTERS.MCOMMENT is
  339. 'Description of the database site'
  340. /
  341. create or replace view ALL_ADMINMASTERS
  342.   (SNAME, DBLINK, MASTERDEF, SNAPMASTER, MCOMMENT)
  343. as
  344. select distinct
  345.   r.sname,
  346.   r.dblink,
  347.   DECODE(r.masterdef, 'Y', 'Yes', 'No'),
  348.   DECODE(r.snapmaster, 'Y', 'Yes', 'No'),
  349.   r.master_comment
  350. from
  351.   all_repschema r
  352. where
  353.   r.dblink not in (select global_name from global_name)
  354. /
  355. comment on table ALL_ADMINMASTERS is
  356. 'N-way replication information'
  357. /
  358. comment on column ALL_ADMINMASTERS.SNAME is
  359. 'Name of the replicated schema'
  360. /
  361. comment on column ALL_ADMINMASTERS.DBLINK is
  362. 'A database site replicating the schema'
  363. /
  364. comment on column ALL_ADMINMASTERS.MASTERDEF is
  365. 'Is the database the master definition site for the replicated schema'
  366. /
  367. comment on column ALL_ADMINMASTERS.SNAPMASTER is
  368. 'For a snapshot site, is the database the current refresh master'
  369. /
  370. comment on column ALL_ADMINMASTERS.MCOMMENT is
  371. 'Description of the database site'
  372. /
  373. drop public synonym ALL_ADMINMASTERS
  374. /
  375. create public synonym ALL_ADMINMASTERS for ALL_ADMINMASTERS
  376. /
  377. grant select on ALL_ADMINMASTERS to PUBLIC with grant option
  378. /
  379. create or replace view USER_ADMINMASTERS
  380.   (SNAME, DBLINK, MASTERDEF, SNAPMASTER, MCOMMENT)
  381. as
  382. select distinct
  383.   r.sname,
  384.   r.dblink,
  385.   DECODE(r.masterdef, 'Y', 'Yes', 'No'),
  386.   DECODE(r.snapmaster, 'Y', 'Yes', 'No'),
  387.   r.master_comment
  388. from
  389.   user_repschema r
  390. where
  391.   r.dblink not in (select global_name from global_name)
  392. /
  393. comment on table USER_ADMINMASTERS is
  394. 'N-way replication information about the current user'
  395. /
  396. comment on column USER_ADMINMASTERS.SNAME is
  397. 'Name of the user'
  398. /
  399. comment on column USER_ADMINMASTERS.DBLINK is
  400. 'A database site replicating the schema'
  401. /
  402. comment on column USER_ADMINMASTERS.MASTERDEF is
  403. 'Is the database the master definition site for the replicated schema'
  404. /
  405. comment on column USER_ADMINMASTERS.SNAPMASTER is
  406. 'For snapshot sites, is the database the current refresh master'
  407. /
  408. comment on column USER_ADMINMASTERS.MCOMMENT is
  409. 'User description of the database site'
  410. /
  411. drop public synonym USER_ADMINMASTERS
  412. /
  413. create public synonym USER_ADMINMASTERS for USER_ADMINMASTERS
  414. /
  415. grant select on USER_ADMINMASTERS to PUBLIC with grant option
  416. /
  417.  
  418.  
  419. --- (4)
  420. ---
  421. create or replace view DBA_ADMINRESOLUTION
  422.   (SNAME, ONAME, UPD_CNT, UNQ_CNT, DEL_CNT)
  423. as
  424. select
  425.   o.sname,
  426.   o.oname,
  427.   SUM(DECODE(r.conflict_type, 'UPDATE', 1, 0)),
  428.   SUM(DECODE(r.conflict_type, 'UNIQUE', 1, 0)),
  429.   SUM(DECODE(r.conflict_type, 'DELETE', 1, 0))
  430. from
  431.   dba_repobject o, dba_represolution r
  432. where
  433.   (o.type = 'TABLE') and
  434.   (o.oname = r.oname (+) and o.sname = r.sname (+))
  435. group by
  436.   o.sname, o.oname
  437. /
  438. comment on table DBA_ADMINRESOLUTION is
  439. 'Description of all conflict resolutions in the database'
  440. /
  441. comment on column DBA_ADMINRESOLUTION.SNAME is
  442. 'Name of the replicated schema'
  443. /
  444. comment on column DBA_ADMINRESOLUTION.ONAME is
  445. 'Name of the replicated table'
  446. /
  447. comment on column DBA_ADMINRESOLUTION.UPD_CNT is
  448. 'Number of update conlict resolution functions declared'
  449. /
  450. comment on column DBA_ADMINRESOLUTION.UNQ_CNT is
  451. 'Number of uniqueness conlict resolution functions declared'
  452. /
  453. comment on column DBA_ADMINRESOLUTION.DEL_CNT is
  454. 'Number of delete conlict resolution functions declared'
  455. /
  456. create or replace view ALL_ADMINRESOLUTION
  457.   (SNAME, ONAME, UPD_CNT, UNQ_CNT, DEL_CNT)
  458. as
  459. select
  460.   o.sname,
  461.   o.oname,
  462.   SUM(DECODE(r.conflict_type, 'UPDATE', 1, 0)),
  463.   SUM(DECODE(r.conflict_type, 'UNIQUE', 1, 0)),
  464.   SUM(DECODE(r.conflict_type, 'DELETE', 1, 0))
  465. from
  466.   all_repobject o, all_represolution r
  467. where
  468.   (o.type = 'TABLE') and
  469.   (o.oname = r.oname (+) and o.sname = r.sname (+))
  470. group by
  471.   o.sname, o.oname
  472. /
  473. comment on table ALL_ADMINRESOLUTION is
  474. 'Description of all conflict resolutions in the database'
  475. /
  476. comment on column ALL_ADMINRESOLUTION.SNAME is
  477. 'Name of the replicated schema'
  478. /
  479. comment on column ALL_ADMINRESOLUTION.ONAME is
  480. 'Name of the replicated table'
  481. /
  482. comment on column ALL_ADMINRESOLUTION.UPD_CNT is
  483. 'Number of update conlict resolution functions declared'
  484. /
  485. comment on column ALL_ADMINRESOLUTION.UNQ_CNT is
  486. 'Number of uniqueness conlict resolution functions declared'
  487. /
  488. comment on column ALL_ADMINRESOLUTION.DEL_CNT is
  489. 'Number of delete conlict resolution functions declared'
  490. /
  491. drop public synonym ALL_ADMINRESOLUTION
  492. /
  493. create public synonym ALL_ADMINRESOLUTION for ALL_ADMINRESOLUTION
  494. /
  495. grant select on ALL_ADMINRESOLUTION to PUBLIC with grant option
  496. /
  497. create or replace view USER_ADMINRESOLUTION
  498.   (SNAME, ONAME, UPD_CNT, UNQ_CNT, DEL_CNT)
  499. as
  500. select
  501.   o.sname,
  502.   o.oname,
  503.   SUM(DECODE(r.conflict_type, 'UPDATE', 1, 0)),
  504.   SUM(DECODE(r.conflict_type, 'UNIQUE', 1, 0)),
  505.   SUM(DECODE(r.conflict_type, 'DELETE', 1, 0))
  506. from
  507.   user_repobject o, user_represolution r
  508. where
  509.   (o.type = 'TABLE') and
  510.   (o.oname = r.oname (+) and o.sname in (select user from dual))
  511. group by
  512.   o.sname, o.oname
  513. /
  514. comment on table USER_ADMINRESOLUTION is
  515. 'Description of all conflict resolutions in the database'
  516. /
  517. comment on column USER_ADMINRESOLUTION.SNAME is
  518. 'Name of the replicated schema'
  519. /
  520. comment on column USER_ADMINRESOLUTION.ONAME is
  521. 'Name of the replicated table'
  522. /
  523. comment on column USER_ADMINRESOLUTION.UPD_CNT is
  524. 'Number of update conlict resolution functions declared'
  525. /
  526. comment on column USER_ADMINRESOLUTION.UNQ_CNT is
  527. 'Number of uniqueness conlict resolution functions declared'
  528. /
  529. comment on column USER_ADMINRESOLUTION.DEL_CNT is
  530. 'Number of delete conlict resolution functions declared'
  531. /
  532. drop public synonym USER_ADMINRESOLUTION
  533. /
  534. create public synonym USER_ADMINRESOLUTION for USER_ADMINRESOLUTION
  535. /
  536. grant select on USER_ADMINRESOLUTION to PUBLIC with grant option
  537. /
  538.  
  539.  
  540. --- (5)
  541. ---
  542. create or replace view DBA_ADMINDEFTRAN
  543.   (DST_LNK, TRN_CNT, LS_TIME, FAILURES, BROKEN)
  544. as
  545. select 
  546.   r.dblink,
  547.   count(distinct d.deferred_tran_id),
  548.   s.last_date,
  549.   DECODE(j.failures, NULL, 0, j.failures),
  550.   DECODE(j.broken, NULL, 'Job Not Found', 'Y', 'Yes', 'No')
  551. from
  552.   deftrandest d, defschedule s, dba_jobs j, dba_repschema r
  553. where
  554.  ((r.dblink not in (select global_name from global_name)) and
  555.     (r.snapmaster = 'Y' or r.snapmaster is NULL)) and
  556.   (r.dblink = d.dblink (+)) and
  557.   (d.dblink = s.dblink (+)) and
  558.   (s.job = j.job (+))
  559. group by r.dblink, s.last_date, j.failures, j.broken
  560. /
  561. comment on table DBA_ADMINDEFTRAN is
  562. 'Descriptions of all queued deferred transactions at the local site'
  563. /
  564. comment on column DBA_ADMINDEFTRAN.DST_LNK is
  565. 'Destination to which the transactions will be propogated'
  566. /
  567. comment on column DBA_ADMINDEFTRAN.TRN_CNT is
  568. 'Number of transactions queued for each destination'
  569. /
  570. comment on column DBA_ADMINDEFTRAN.LS_TIME is
  571. 'Last time of push for each destination by the jobqueues process'
  572. /
  573. comment on column DBA_ADMINDEFTRAN.FAILURES is
  574. 'Number of failures which attempting to push the queue for each dest'
  575. /
  576. comment on column DBA_ADMINDEFTRAN.BROKEN is
  577. 'Broken status if the jobqueues process which pushes the transactions'
  578. /
  579.  
  580.  
  581. --- (6)
  582. ---
  583. create or replace view DBA_ADMINDEFERROR
  584.   (DB, ID, CALLNO, DESTINATION, ERROR_TIME, ERROR_NUMBER, 
  585.    ERROR_MSG)
  586. as
  587. select
  588.   deferred_tran_db,
  589.   deferred_tran_id,
  590.   callno,
  591.   destination,
  592.   error_time,
  593.   error_number,
  594.   error_msg
  595. from
  596.   deferror
  597. /
  598. comment on table DBA_ADMINDEFERROR is
  599. 'Information on unresolved error occuring at the local site'
  600. /
  601. comment On column DBA_ADMINDEFERROR.DB is
  602. 'Global database name of initiating database'
  603. /
  604. comment on column DBA_ADMINDEFERROR.ID is
  605. 'Unique ID assigned to deferred transaction causing error'
  606. /
  607. comment on column DBA_ADMINDEFERROR.DESTINATION is
  608. 'DBLink used to address destination'
  609. /
  610. comment on column DBA_ADMINDEFERROR.ERROR_TIME is
  611. 'Time of error'
  612. /
  613. comment on column DBA_ADMINDEFERROR.ERROR_NUMBER is
  614. 'Oracle error number'
  615. /
  616. comment on column DBA_ADMINDEFERROR.ERROR_MSG is
  617. 'Error message text'
  618. /
  619.  
  620.  
  621. --- (7) 
  622. --- 
  623. create or replace view DBA_ADMINCATLOG
  624.   (ID, SOURCE, USERID, TIMESTAMP, ROLE, REQUEST, ONAME, SNAME, 
  625.    STATUS, MESSAGE, ERRNUM)
  626. as
  627. select
  628.   id,
  629.   source,
  630.   userid,
  631.   timestamp,
  632.   role,
  633.   request,
  634.   oname,
  635.   sname,
  636.   status,
  637.   message,
  638.   errnum
  639. from
  640.   dba_repcatlog
  641. /
  642. comment on table DBA_ADMINCATLOG is
  643. 'Information about asynchronous administration requests'
  644. /
  645. comment on column DBA_ADMINCATLOG.ID is
  646. 'Identifying number of repcat log record'
  647. /
  648. comment on column DBA_ADMINCATLOG.SOURCE is
  649. 'Name of the database at which the request originated'
  650. /
  651. comment on column DBA_ADMINCATLOG.STATUS is
  652. 'Status of the request at this database'
  653. /
  654. comment on column DBA_ADMINCATLOG.USERID is
  655. 'Name of the user who submitted the request'
  656. /
  657. comment on column DBA_ADMINCATLOG.TIMESTAMP is
  658. 'When the request was submitted'
  659. /
  660. comment on column DBA_ADMINCATLOG.ROLE is
  661. 'Is this database the masterdef for the request'
  662. /
  663. comment on column DBA_ADMINCATLOG.SNAME is
  664. 'Name of the replicated schema'
  665. /
  666. comment on column DBA_ADMINCATLOG.REQUEST is
  667. 'Name of the requested operation'
  668. /
  669. comment on column DBA_ADMINCATLOG.ONAME is
  670. 'Replicated object name, if applicable'
  671. /
  672. comment on column DBA_ADMINCATLOG.MESSAGE is
  673. 'Error message associated with processing the request'
  674. /
  675. comment on column DBA_ADMINCATLOG.ERRNUM is
  676. 'Oracle error number associated with processing the request'
  677. /
  678. create or replace view ALL_ADMINCATLOG
  679.   (ID, SOURCE, USERID, TIMESTAMP, ROLE, REQUEST, ONAME, SNAME, 
  680.    STATUS, MESSAGE, ERRNUM)
  681. as
  682. select
  683.   id,
  684.   source,
  685.   userid,
  686.   timestamp,
  687.   role,
  688.   request,
  689.   oname,
  690.   sname,
  691.   status,
  692.   message,
  693.   errnum
  694. from
  695.   all_repcatlog
  696. /
  697. comment on table ALL_ADMINCATLOG is
  698. 'Information about asynchronous administration requests'
  699. /
  700. comment on column ALL_ADMINCATLOG.ID is
  701. 'Identifying number of repcat log record'
  702. /
  703. comment on column ALL_ADMINCATLOG.SOURCE is
  704. 'Name of the database at which the request originated'
  705. /
  706. comment on column ALL_ADMINCATLOG.USERID is
  707. 'Name of the user who submitted the request'
  708. /
  709. comment on column ALL_ADMINCATLOG.TIMESTAMP is
  710. 'When the request was submitted'
  711. /
  712. comment on column ALL_ADMINCATLOG.ROLE is
  713. 'Is this database the masterdef for the request'
  714. /
  715. comment on column ALL_ADMINCATLOG.SNAME is
  716. 'Name of the replicated schema'
  717. /
  718. comment on column ALL_ADMINCATLOG.REQUEST is
  719. 'Name of the requested operation'
  720. /
  721. comment on column ALL_ADMINCATLOG.ONAME is
  722. 'Replicated object name, if applicable'
  723. /
  724. comment on column ALL_ADMINCATLOG.STATUS is
  725. 'Status of the request at this database'
  726. /
  727. comment on column ALL_ADMINCATLOG.MESSAGE is
  728. 'Error message associated with processing the request'
  729. /
  730. comment on column ALL_ADMINCATLOG.ERRNUM is
  731. 'Oracle error number associated with processing the request'
  732. /
  733. drop public synonym ALL_ADMINCATLOG
  734. /
  735. create public synonym ALL_ADMINCATLOG for ALL_ADMINCATLOG
  736. /
  737. grant select on ALL_ADMINCATLOG to PUBLIC with grant option
  738. /
  739. create or replace view USER_ADMINCATLOG
  740.   (ID, SOURCE, USERID, TIMESTAMP, ROLE, REQUEST, ONAME, SNAME, 
  741.    STATUS, MESSAGE, ERRNUM)
  742. as
  743. select
  744.   id,
  745.   source,
  746.   userid,
  747.   timestamp,
  748.   role,
  749.   request,
  750.   oname,
  751.   sname,
  752.   status,
  753.   message,
  754.   errnum
  755. from
  756.   user_repcatlog
  757. /
  758. comment on table USER_ADMINCATLOG is
  759. 'Information about the current user''s asynchronous administration requests'
  760. /
  761. comment on column USER_ADMINCATLOG.ID is
  762. 'Identifying number of repcat log record'
  763. /
  764. comment on column USER_ADMINCATLOG.SOURCE is
  765. 'Name of the database at which the request originated'
  766. /
  767. comment on column USER_ADMINCATLOG.USERID is
  768. 'Name of the user who submitted the request'
  769. /
  770. comment on column USER_ADMINCATLOG.TIMESTAMP is
  771. 'When the request was submitted'
  772. /
  773. comment on column USER_ADMINCATLOG.ROLE is
  774. 'Is this database the masterdef for the request'
  775. /
  776. comment on column USER_ADMINCATLOG.SNAME is
  777. 'Name of the replicated schema'
  778. /
  779. comment on column USER_ADMINCATLOG.REQUEST is
  780. 'Name of the requested operation'
  781. /
  782. comment on column USER_ADMINCATLOG.ONAME is
  783. 'Replicated object name, if applicable'
  784. /
  785. comment on column USER_ADMINCATLOG.STATUS is
  786. 'Status of the request at this database'
  787. /
  788. comment on column USER_ADMINCATLOG.MESSAGE is
  789. 'Error message associated with processing the request'
  790. /
  791. comment on column USER_ADMINCATLOG.ERRNUM is
  792. 'Oracle error number associated with processing the request'
  793. /
  794. drop public synonym USER_ADMINCATLOG
  795. /
  796. create public synonym USER_ADMINCATLOG for USER_ADMINCATLOG
  797. /
  798. grant select on USER_ADMINCATLOG to PUBLIC with grant option
  799. /
  800.  
  801.  
  802. --- (8)
  803. ---
  804. create or replace view DBA_ADMINREGSNAPS
  805.   (NAME, SNAME, TABLE_NAME, M_VIEW, M_OWNER, MASTER, M_LINK, LOG,
  806.     UPD, LAST_REFRESH, ERROR, TYPE, NEXT, START_W, RG, UPD_TRG, 
  807.     UPD_LOG, QRY, OBJ_COM)
  808. as
  809. select
  810.   s.name,
  811.   s.owner,
  812.   s.table_name,
  813.   s.master_view,
  814.   s.master_owner,
  815.   s.master,
  816.   s.master_link,
  817.   s.can_use_log,
  818.   s.updatable,
  819.   s.last_refresh,
  820.   s.error,
  821.   s.type,
  822.   s.next,
  823.   s.start_with,
  824.   f.rname,
  825.   s.update_trig,
  826.   s.update_log,
  827.   s.query,
  828.   r.object_comment
  829. from 
  830.   dba_snapshots s, 
  831.   dba_repobject r,
  832.   dba_refresh f
  833. where
  834.   r.type = 'SNAPSHOT' and
  835.   (s.name = r.oname  and s.owner = r.sname) and
  836.   s.refresh_group = f.refgroup (+)
  837. /
  838. comment on table DBA_ADMINREGSNAPS is
  839. 'All snapshots in the database'
  840. /
  841. comment on column DBA_ADMINREGSNAPS.SNAME is
  842. 'Owner of the snapshot'
  843. /
  844. comment on column DBA_ADMINREGSNAPS.NAME is
  845. 'The view used by users and applications for viewing the snapshot'
  846. /
  847. comment on column DBA_ADMINREGSNAPS.TABLE_NAME is
  848. 'Table the snapshot is stored in -- has an extra column for the master rowid'
  849. /
  850. comment on column DBA_ADMINREGSNAPS.M_VIEW is
  851. 'View of the master table, owned by the snapshot owner, used for refreshes'
  852. /
  853. comment on column DBA_ADMINREGSNAPS.M_OWNER is
  854. 'Owner of the master table'
  855. /
  856. comment on column DBA_ADMINREGSNAPS.MASTER is
  857. 'Name of the master table that this snapshot is a copy of'
  858. /
  859. comment on column DBA_ADMINREGSNAPS.M_LINK is
  860. 'Database link name to the master site'
  861. /
  862. comment on column DBA_ADMINREGSNAPS.LOG is
  863. 'If NO, this snapshot is complex and will never use a log'
  864. /
  865. comment on column DBA_ADMINREGSNAPS.UPD is
  866. 'If NO, the snapshot is read only.  Look up REPLICATION'
  867. /
  868. comment on column DBA_ADMINREGSNAPS.LAST_REFRESH is
  869. 'SYSDATE from the master site at the time of the last refresh'
  870. /
  871. comment on column DBA_ADMINREGSNAPS.ERROR is
  872. 'The number of failed automatic refreshes since last successful refresh'
  873. /
  874. comment on column DBA_ADMINREGSNAPS.TYPE is
  875. 'The type of refresh (complete,fast,force) for all automatic refreshes'
  876. /
  877. comment on column DBA_ADMINREGSNAPS.NEXT is
  878. 'The date function used to compute next refresh dates'
  879. /
  880. comment on column DBA_ADMINREGSNAPS.START_W is
  881. 'The date function used to compute next refresh dates'
  882. /
  883. comment on column DBA_ADMINREGSNAPS.RG is
  884. 'All snapshots in a given refresh group get refreshed in the same transaction'
  885. /
  886. comment on column DBA_ADMINREGSNAPS.UPD_TRG is
  887. 'The name of the trigger which fills the UPDATE_LOG'
  888. /
  889. comment on column DBA_ADMINREGSNAPS.UPD_LOG is
  890. 'The table which logs changes made to an updatable snapshots'
  891. /
  892. comment on column DBA_ADMINREGSNAPS.QRY is
  893. 'The original query that this snapshot is an instantiation of'
  894. /
  895. comment on column DBA_ADMINREGSNAPS.OBJ_COM is
  896. 'Description for snapshot'
  897. /
  898. create or replace view ALL_ADMINREGSNAPS
  899.   (NAME, SNAME, TABLE_NAME, M_VIEW, M_OWNER, MASTER, M_LINK, LOG,
  900.     UPD, LAST_REFRESH, ERROR, TYPE, NEXT, START_W, RG, UPD_TRG, 
  901.     UPD_LOG, QRY, OBJ_COM)
  902. as
  903. select
  904.   s.name,
  905.   s.owner,
  906.   s.table_name,
  907.   s.master_view,
  908.   s.master_owner,
  909.   s.master,
  910.   s.master_link,
  911.   s.can_use_log,
  912.   s.updatable,
  913.   s.last_refresh,
  914.   s.error,
  915.   s.type,
  916.   s.next,
  917.   s.start_with,
  918.   f.rname,
  919.   s.update_trig,
  920.   s.update_log,
  921.   s.query,
  922.   r.object_comment
  923. from 
  924.   all_snapshots s, 
  925.   all_repobject r,
  926.   all_refresh f
  927. where
  928.   r.type = 'SNAPSHOT' and
  929.   (s.name = r.oname  and s.owner = r.sname) and
  930.   s.refresh_group = f.refgroup (+)
  931. /
  932. comment on table ALL_ADMINREGSNAPS is
  933. 'All snapshots in the database'
  934. /
  935. comment on column ALL_ADMINREGSNAPS.SNAME is
  936. 'Owner of the snapshot'
  937. /
  938. comment on column ALL_ADMINREGSNAPS.NAME is
  939. 'The view used by users and applications for viewing the snapshot'
  940. /
  941. comment on column ALL_ADMINREGSNAPS.TABLE_NAME is
  942. 'Table the snapshot is stored in -- has an extra column for the master rowid'
  943. /
  944. comment on column ALL_ADMINREGSNAPS.M_VIEW is
  945. 'View of the master table, owned by the snapshot owner, used for refreshes'
  946. /
  947. comment on column ALL_ADMINREGSNAPS.M_OWNER is
  948. 'Owner of the master table'
  949. /
  950. comment on column ALL_ADMINREGSNAPS.MASTER is
  951. 'Name of the master table that this snapshot is a copy of'
  952. /
  953. comment on column ALL_ADMINREGSNAPS.M_LINK is
  954. 'Database link name to the master site'
  955. /
  956. comment on column ALL_ADMINREGSNAPS.LOG is
  957. 'If NO, this snapshot is complex and will never use a log'
  958. /
  959. comment on column ALL_ADMINREGSNAPS.UPD is
  960. 'If NO, the snapshot is read only.  Look up REPLICATION'
  961. /
  962. comment on column ALL_ADMINREGSNAPS.LAST_REFRESH is
  963. 'SYSDATE from the master site at the time of the last refresh'
  964. /
  965. comment on column ALL_ADMINREGSNAPS.ERROR is
  966. 'The number of failed automatic refreshes since last successful refresh'
  967. /
  968. comment on column ALL_ADMINREGSNAPS.TYPE is
  969. 'The type of refresh (complete,fast,force) for all automatic refreshes'
  970. /
  971. comment on column ALL_ADMINREGSNAPS.NEXT is
  972. 'The date function used to compute next refresh dates'
  973. /
  974. comment on column ALL_ADMINREGSNAPS.START_W is
  975. 'The date function used to compute next refresh dates'
  976. /
  977. comment on column ALL_ADMINREGSNAPS.RG is
  978. 'All snapshots in a given refresh group get refreshed in the same transaction'
  979. /
  980. comment on column ALL_ADMINREGSNAPS.UPD_TRG is
  981. 'The name of the trigger which fills the UPDATE_LOG'
  982. /
  983. comment on column ALL_ADMINREGSNAPS.UPD_LOG is
  984. 'The table which logs changes made to an updatable snapshots'
  985. /
  986. comment on column ALL_ADMINREGSNAPS.QRY is
  987. 'The original query that this snapshot is an instantiation of'
  988. /
  989. comment on column ALL_ADMINREGSNAPS.OBJ_COM is
  990. 'Description for snapshot'
  991. /
  992. drop public synonym ALL_ADMINREGSNAPS
  993. /
  994. create public synonym ALL_ADMINREGSNAPS for ALL_ADMINREGSNAPS
  995. /
  996. grant select on ALL_ADMINREGSNAPS to public with grant option
  997. /
  998. create or replace view USER_ADMINREGSNAPS
  999.   (NAME, SNAME, TABLE_NAME, M_VIEW, M_OWNER, MASTER, M_LINK, LOG,
  1000.     UPD, LAST_REFRESH, ERROR, TYPE, NEXT, START_W, RG, UPD_TRG, 
  1001.     UPD_LOG, QRY, OBJ_COM)
  1002. as
  1003. select
  1004.   s.name,
  1005.   s.owner,
  1006.   s.table_name,
  1007.   s.master_view,
  1008.   s.master_owner,
  1009.   s.master,
  1010.   s.master_link,
  1011.   s.can_use_log,
  1012.   s.updatable,
  1013.   s.last_refresh,
  1014.   s.error,
  1015.   s.type,
  1016.   s.next,
  1017.   s.start_with,
  1018.   f.rname,
  1019.   s.update_trig,
  1020.   s.update_log,
  1021.   s.query,
  1022.   r.object_comment
  1023. from 
  1024.   user_snapshots s, 
  1025.   user_repobject r,
  1026.   user_refresh f
  1027. where
  1028.   r.type = 'SNAPSHOT' and
  1029.   (s.name = r.oname  and s.owner = r.sname) and
  1030.   s.refresh_group = f.refgroup (+)
  1031. /
  1032. comment on table USER_ADMINREGSNAPS is
  1033. 'All snapshots in the database'
  1034. /
  1035. comment on column USER_ADMINREGSNAPS.SNAME is
  1036. 'Owner of the snapshot'
  1037. /
  1038. comment on column USER_ADMINREGSNAPS.NAME is
  1039. 'The view used by users and applications for viewing the snapshot'
  1040. /
  1041. comment on column USER_ADMINREGSNAPS.TABLE_NAME is
  1042. 'Table the snapshot is stored in -- has an extra column for the master rowid'
  1043. /
  1044. comment on column USER_ADMINREGSNAPS.M_VIEW is
  1045. 'View of the master table, owned by the snapshot owner, used for refreshes'
  1046. /
  1047. comment on column USER_ADMINREGSNAPS.M_OWNER is
  1048. 'Owner of the master table'
  1049. /
  1050. comment on column USER_ADMINREGSNAPS.MASTER is
  1051. 'Name of the master table that this snapshot is a copy of'
  1052. /
  1053. comment on column USER_ADMINREGSNAPS.M_LINK is
  1054. 'Database link name to the master site'
  1055. /
  1056. comment on column USER_ADMINREGSNAPS.LOG is
  1057. 'If NO, this snapshot is complex and will never use a log'
  1058. /
  1059. comment on column USER_ADMINREGSNAPS.UPD is
  1060. 'If NO, the snapshot is read only.  Look up REPLICATION'
  1061. /
  1062. comment on column USER_ADMINREGSNAPS.LAST_REFRESH is
  1063. 'SYSDATE from the master site at the time of the last refresh'
  1064. /
  1065. comment on column USER_ADMINREGSNAPS.ERROR is
  1066. 'The number of failed automatic refreshes since last successful refresh'
  1067. /
  1068. comment on column USER_ADMINREGSNAPS.TYPE is
  1069. 'The type of refresh (complete,fast,force) for all automatic refreshes'
  1070. /
  1071. comment on column USER_ADMINREGSNAPS.NEXT is
  1072. 'The date function used to compute next refresh dates'
  1073. /
  1074. comment on column USER_ADMINREGSNAPS.START_W is
  1075. 'The date function used to compute next refresh dates'
  1076. /
  1077. comment on column USER_ADMINREGSNAPS.RG is
  1078. 'All snapshots in a given refresh group get refreshed in the same transaction'
  1079. /
  1080. comment on column USER_ADMINREGSNAPS.UPD_TRG is
  1081. 'The name of the trigger which fills the UPDATE_LOG'
  1082. /
  1083. comment on column USER_ADMINREGSNAPS.UPD_LOG is
  1084. 'The table which logs changes made to an updatable snapshots'
  1085. /
  1086. comment on column USER_ADMINREGSNAPS.QRY is
  1087. 'The original query that this snapshot is an instantiation of'
  1088. /
  1089. comment on column USER_ADMINREGSNAPS.OBJ_COM is
  1090. 'Description for snapshot'
  1091. /
  1092. drop public synonym USER_ADMINREGSNAPS
  1093. /
  1094. create public synonym USER_ADMINREGSNAPS for USER_ADMINREGSNAPS
  1095. /
  1096. grant select on USER_ADMINREGSNAPS to public with grant option
  1097. /
  1098.  
  1099. commit
  1100. /
  1101.  
  1102. -----------------------------------------------------
  1103. --- Load the package to print deferred call arguments
  1104. -----------------------------------------------------
  1105. CREATE OR REPLACE PACKAGE dbms_defer_print IS
  1106.  
  1107.   PROCEDURE print_deftran(deferred_tran_id IN VARCHAR2 := NULL,
  1108.                           deferred_tran_db IN VARCHAR2 := NULL,
  1109.                           destination      IN VARCHAR2 := NULL,
  1110.                           callno           IN NUMBER,
  1111.                           date_format      IN VARCHAR2 :=
  1112.                                               'YY:MM:DD:HH24:MI:SS',
  1113.                           save_output      IN BOOLEAN := FALSE,
  1114.                           schema_name      IN VARCHAR2 := NULL,
  1115.                           table_name       IN VARCHAR2 := NULL,
  1116.                           tag              IN VARCHAR2 := NULL);
  1117.   -- Use dbms_output to print information about deferred remote procedure calls
  1118.   -- for transactions in deftran.  For each deferred call, the procedure prints
  1119.   -- information about each parameter including its name, datatype, and value.
  1120.   -- The name and datatype are determined by describing the local version of
  1121.   -- the procedure.
  1122.   --
  1123.   -- The first three parameters can be used to limit which transactions are
  1124.   -- printed.  For these parameters, a NULL is treated as a wildcard.
  1125.   -- The date_format parameter is the format for printing dates.
  1126.   -- If save_output is TRUE, the output is saved in the table given by
  1127.   -- schema_name and table_name and the TAG column is filled with the
  1128.   -- value of parameter tag.  The output table must have at least the columns
  1129.   -- in a table created by create_unpacked_table.
  1130.  
  1131.   PROCEDURE print_deferror(deferred_tran_id IN VARCHAR2 := NULL,
  1132.                            deferred_tran_db IN VARCHAR2 := NULL,
  1133.                            callno           IN NUMBER,
  1134.                            date_format      IN VARCHAR2 :=
  1135.                                               'YY:MM:DD:HH24:MI:SS',
  1136.                            save_output      IN BOOLEAN := FALSE,
  1137.                            schema_name      IN VARCHAR2 := NULL,
  1138.                            table_name       IN VARCHAR2 := NULL,
  1139.                            tag              IN VARCHAR2 := NULL);
  1140.   -- Use dbms_output to print information about deferred remote procedure calls
  1141.   -- for transactions in deferror.  For each deferred call, the procedure
  1142.   -- prints information about each parameter including its name, datatype,
  1143.   -- and value.
  1144.   --
  1145.   -- The first two parameters can be used to limit which transactions are
  1146.   -- printed.  For these parameters, a NULL is treated as a wildcard.
  1147.   -- The date_format parameter is the format for printing dates.
  1148.   -- If save_output is TRUE, the output is saved in the table given by
  1149.   -- schema_name and table_name and the TAG column is filled with the
  1150.   -- value of parameter tag.  The output table must have at least the columns
  1151.   -- in a table created by create_unpacked_table.
  1152.  
  1153.   PROCEDURE create_unpacked_table(schema_name IN VARCHAR2 := NULL,
  1154.                                   table_name  IN VARCHAR2 := NULL);
  1155.   -- Create a table for unpacking the information about deferred remote
  1156.   -- procedure calls.  A NULL schema_name uses the current schema, while
  1157.   -- a NULL table_name uses 'DEFUNPACKED'.
  1158.  
  1159.   FUNCTION return_name(idx IN BINARY_INTEGER) RETURN VARCHAR2;
  1160.   PRAGMA RESTRICT_REFERENCES(return_name, WNDS, WNPS);
  1161.  
  1162.   FUNCTION return_type(idx IN BINARY_INTEGER) RETURN VARCHAR2;
  1163.   PRAGMA RESTRICT_REFERENCES(return_type, WNDS, WNPS);
  1164.  
  1165.   FUNCTION return_value(idx IN BINARY_INTEGER) RETURN VARCHAR2;
  1166.   PRAGMA RESTRICT_REFERENCES(return_value, WNDS, WNPS);
  1167.  
  1168.  
  1169. END dbms_defer_print;
  1170. /
  1171. show errors
  1172.  
  1173.  
  1174. CREATE OR REPLACE PACKAGE BODY dbms_defer_print IS
  1175.  
  1176.   TYPE argnmtab IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
  1177.   TYPE argtptab IS TABLE OF VARCHAR2(8) INDEX BY BINARY_INTEGER;
  1178.   TYPE argvltab IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;
  1179.  
  1180.   local_node VARCHAR2(128);      -- cache global_name column from global_name
  1181.   num_args number;               -- number of arguments
  1182.   arg_names argnmtab;                     -- argument names
  1183.   arg_types argtptab;                     -- argument types
  1184.   arg_values argvltab;                    -- argument values
  1185.  
  1186.   PROCEDURE canonicalize(name       IN  VARCHAR2,
  1187.                          canon_name OUT VARCHAR2,
  1188.                          canon_len  IN  NUMBER) IS
  1189.   -- canonicalize the given non-NULL string
  1190.   -- if name begins and ends with a double quote, remove both
  1191.   -- otherwise, convert to upper case with NLS_UPPER
  1192.   -- return the first canon_len characters in canon_name
  1193.   name_length NUMBER;
  1194.  
  1195.   BEGIN
  1196.     name_length := LENGTH(name);
  1197.     IF SUBSTR(name, 1, 1) = '"' AND SUBSTR(name, name_length, 1) = '"' THEN
  1198.       canon_name := SUBSTR(SUBSTR(name, 2, name_length-2), 1, canon_len);
  1199.     ELSE canon_name := NLS_UPPER(SUBSTR(name, 1, canon_len));
  1200.     END IF;
  1201.   END canonicalize;
  1202.  
  1203.  
  1204.   PROCEDURE get_unpacked_table_name(schema_name IN  VARCHAR2,
  1205.                                     table_name  IN  VARCHAR2,
  1206.                                     output      OUT VARCHAR2) IS
  1207.   -- supply defaults for NULL parameters
  1208.   real_schema VARCHAR2(33);
  1209.   real_table  VARCHAR2(32);
  1210.   canon_name  VARCHAR2(30);
  1211.  
  1212.   BEGIN
  1213.     IF schema_name IS NULL THEN real_schema := NULL;
  1214.     ELSE
  1215.       canonicalize(schema_name, canon_name, 30);
  1216.       real_schema := '"' || canon_name || '".';
  1217.     END IF;
  1218.     IF table_name IS NULL THEN real_table := 'DEFUNPACKED';
  1219.     ELSE
  1220.       canonicalize(table_name, canon_name, 30);
  1221.       real_table := '"' || canon_name || '"';
  1222.     END IF;
  1223.     output := real_schema || real_table;
  1224.   END get_unpacked_table_name;
  1225.  
  1226.  
  1227.   FUNCTION advance(tab_values IN dbms_describe.number_table,
  1228.                    offset     IN BINARY_INTEGER) RETURN BINARY_INTEGER IS
  1229.   -- Offset is an index into tab_values.
  1230.   -- Calculate the smallest BINARY_INTEGER greater than offset that leads
  1231.   -- either to a different value in tab_values or to an empty slot in
  1232.   -- tab_values.
  1233.   new_offset BINARY_INTEGER := offset + 1;  -- holds the result
  1234.  
  1235.   BEGIN
  1236.     BEGIN
  1237.       WHILE tab_values(new_offset) = tab_values(offset) LOOP
  1238.         new_offset := new_offset + 1;
  1239.       END LOOP;
  1240.     EXCEPTION WHEN no_data_found THEN NULL;
  1241.     END;
  1242.     RETURN new_offset;
  1243.   END advance;
  1244.  
  1245.  
  1246.   FUNCTION which_proc(overload         IN dbms_describe.number_table,
  1247.                       position         IN dbms_describe.number_table,
  1248.                       datatype         IN dbms_describe.number_table,
  1249.                       argcount         IN NUMBER,
  1250.                       callno           IN NUMBER,
  1251.                       deferred_tran_id IN VARCHAR2,
  1252.                       deferred_tran_db IN VARCHAR2) RETURN BINARY_INTEGER IS
  1253.   -- The first three parameters are from dbms_describe.describe_procedure
  1254.   --   and describe all overloaded versions of a given procedure.
  1255.   -- The last three parameters identify a deferred call.
  1256.   -- Argcount tells how many parameters are in the deferred call.
  1257.   -- Determine which version of an overloaded procedure matches the call.
  1258.   -- Calculate and return the offset of the first parameter of this version.
  1259.   answer          BINARY_INTEGER := 1;  -- points to each first parameter
  1260.                                         -- and eventually holds the result
  1261.   parameter_index BINARY_INTEGER := 1;  -- iterate over each parameter
  1262.   arg             BINARY_INTEGER;
  1263.   match           BOOLEAN;
  1264.   arg_type        NUMBER;
  1265.   describe_type   NUMBER;
  1266.   dummy           NUMBER;
  1267.  
  1268.   BEGIN
  1269.     WHILE TRUE LOOP
  1270.       match := TRUE;
  1271.       -- iterate over the procedures
  1272.       -- if this procedure matches, return the offset
  1273.       -- otherwise, advance to the next procedure
  1274.       FOR arg IN 1..argcount LOOP
  1275.         arg_type := dbms_defer_query.get_arg_type(callno, deferred_tran_db,
  1276.                                                   arg, deferred_tran_id);
  1277.         -- a deferred RPC maps a CHAR into a VARCHAR2
  1278.         describe_type := datatype(parameter_index);
  1279.         IF describe_type = dbms_defer.arg_type_char
  1280.           AND arg_type = dbms_defer.arg_type_varchar2 THEN
  1281.           describe_type := dbms_defer.arg_type_varchar2;
  1282.         END IF;
  1283.         IF describe_type != arg_type THEN
  1284.           match := FALSE;
  1285.           EXIT;
  1286.         END IF;
  1287.         -- advance to next parameter
  1288.         parameter_index := advance(position, parameter_index);
  1289.       END LOOP;
  1290.       IF match THEN RETURN answer;
  1291.       END IF;
  1292.       -- advance to next procedure, if any
  1293.       answer := advance(overload, answer);
  1294.       dummy := overload(answer);  -- ensure we have not run off the end
  1295.     END LOOP;
  1296.   EXCEPTION WHEN no_data_found THEN RETURN 1;   -- safest to start at the top
  1297.   END which_proc;
  1298.  
  1299.  
  1300.   FUNCTION print_arg(arg              IN BINARY_INTEGER,
  1301.                      callno           IN NUMBER,
  1302.                      deferred_tran_id IN VARCHAR2,
  1303.                      deferred_tran_db IN VARCHAR2,
  1304.                      date_format      IN VARCHAR2,
  1305.                      offset           IN BINARY_INTEGER,
  1306.                      position         IN dbms_describe.number_table,
  1307.                      argument_name    IN dbms_describe.varchar2_table,
  1308.                      table_name       IN VARCHAR2,
  1309.                      tag              IN VARCHAR2,
  1310.                      dblink           IN VARCHAR2,
  1311.                      delivery_order   IN NUMBER,
  1312.                      procedure_name   IN VARCHAR2) RETURN BINARY_INTEGER IS
  1313.   -- The first four parameters identify a parameter to a deferred RPC.
  1314.   -- Offset, position, and argument_name supply describe information for
  1315.   --   the parameter.
  1316.   -- Print the parameter's position, name, datatype, and first 200 bytes of
  1317.   --   value with dbms_output.
  1318.   -- If table_name is not null, insert a row into the given table tagged
  1319.   --   with tag.
  1320.   -- Return the offset of the next parameter.
  1321.   new_offset    BINARY_INTEGER;
  1322.   print_type    VARCHAR2(8);
  1323.   max_print_len NUMBER := 200;    -- maximum length of parameter we will print
  1324.   sql_cursor    NUMBER;
  1325.   dummy         NUMBER;
  1326.   arg_type      NUMBER;
  1327.   arg_num       NUMBER;
  1328.   arg_char      CHAR(32767);
  1329.   arg_varchar2  VARCHAR2(32767);
  1330.   arg_date      DATE;
  1331.   arg_rowid     ROWID;
  1332.   arg_raw       RAW(32767);
  1333.   arg_name      VARCHAR2(30) := argument_name(offset);
  1334.  
  1335.   BEGIN
  1336.     arg_type := dbms_defer_query.get_arg_type(callno, deferred_tran_db, arg,
  1337.                                               deferred_tran_id);
  1338.     ---|||
  1339.     arg_names(arg) := arg_name;
  1340.     ---|||
  1341.  
  1342.     IF arg_type = dbms_defer.arg_type_num THEN
  1343.       print_type := 'NUMBER';
  1344.       arg_num :=
  1345.         dbms_defer_query.get_number_arg(callno, deferred_tran_db, arg);
  1346.       dbms_output.put_line('--' || TO_CHAR(arg) || '. ' || arg_name ||
  1347.                            ' NUMBER: ' || TO_CHAR(arg_num));
  1348.     ---|||
  1349.       arg_types(arg)  := print_type;
  1350.       arg_values(arg) := TO_CHAR(arg_num);
  1351.     ---|||
  1352.     ELSIF arg_type = dbms_defer.arg_type_char THEN
  1353.       print_type := 'CHAR';
  1354.       arg_varchar2 := SUBSTR(
  1355.          dbms_defer_query.get_char_arg(callno, deferred_tran_db, arg),
  1356.          1, max_print_len);
  1357.       dbms_output.put_line('--' || TO_CHAR(arg) || '. ' || arg_name ||
  1358.                            ' CHAR: ' || arg_varchar2); 
  1359.       arg_varchar2 := SUBSTR(
  1360.          dbms_defer_query.get_char_arg(callno, deferred_tran_db, arg),
  1361.          1, 255);
  1362.     ---|||
  1363.       arg_types(arg)  := print_type;
  1364.       arg_values(arg) := arg_varchar2;
  1365.     ---|||
  1366.     ELSIF arg_type = dbms_defer.arg_type_varchar2 THEN
  1367.       print_type := 'VARCHAR2';
  1368.       arg_varchar2 := SUBSTR(
  1369.          dbms_defer_query.get_varchar2_arg(callno, deferred_tran_db, arg),
  1370.          1, max_print_len);
  1371.       dbms_output.put_line('--' || TO_CHAR(arg) || '. ' || arg_name ||
  1372.                            ' VARCHAR2: ' || arg_varchar2);
  1373.       arg_varchar2 := SUBSTR(
  1374.          dbms_defer_query.get_varchar2_arg(callno, deferred_tran_db, arg),
  1375.          1, 2000);
  1376.     ---|||
  1377.       arg_types(arg)  := print_type;
  1378.       arg_values(arg) := arg_varchar2;
  1379.     ---|||
  1380.     ELSIF arg_type = dbms_defer.arg_type_date THEN
  1381.       print_type := 'DATE';
  1382.       arg_date :=
  1383.         dbms_defer_query.get_date_arg(callno, deferred_tran_db, arg);
  1384.       dbms_output.put_line('--' || TO_CHAR(arg) || '. ' || arg_name ||
  1385.                            ' DATE: ' || TO_CHAR(arg_date, date_format));
  1386.     ---|||
  1387.       arg_types(arg)  := print_type;
  1388.       arg_values(arg) := TO_CHAR(arg_date, date_format);
  1389.     ---|||
  1390.     ELSIF arg_type = dbms_defer.arg_type_rowid THEN
  1391.       print_type := 'ROWID';
  1392.       arg_rowid :=
  1393.         dbms_defer_query.get_rowid_arg(callno, deferred_tran_db, arg);
  1394.       dbms_output.put_line('--' || TO_CHAR(arg) || '. ' || arg_name ||
  1395.                            ' ROWID: ' || ROWIDTOCHAR(arg_rowid));
  1396.     ---|||
  1397.       arg_types(arg)  := print_type;
  1398.       arg_values(arg) := ROWIDTOCHAR(arg_rowid);
  1399.     ---|||
  1400.     ELSIF arg_type = dbms_defer.arg_type_raw THEN
  1401.       print_type := 'RAW';
  1402.       arg_raw :=  SUBSTR(
  1403.          dbms_defer_query.get_raw_arg(callno, deferred_tran_db, arg),
  1404.          1, max_print_len);
  1405.       dbms_output.put_line('--' || TO_CHAR(arg) || '. ' || arg_name ||
  1406.                            ' RAW: ' || RAWTOHEX(arg_raw));
  1407.       arg_raw :=  SUBSTR(
  1408.          dbms_defer_query.get_raw_arg(callno, deferred_tran_db, arg),
  1409.          1, 255);
  1410.     ---|||
  1411.       arg_types(arg)  := print_type;
  1412.       arg_values(arg) := RAWTOHEX(arg_raw);
  1413.     ---|||
  1414.     ELSE
  1415.       RAISE no_data_found;
  1416.     END IF;
  1417.     IF table_name IS NOT NULL THEN
  1418.       sql_cursor := dbms_sql.open_cursor;
  1419.       dbms_sys_sql.parse_as_user(sql_cursor,
  1420.         ' INSERT INTO ' || table_name || '(' ||
  1421.            'tag, deferred_tran_db, deferred_tran_id, dblink, ' ||
  1422.            'delivery_order, callno, procedure, argument, argument_name, ' ||
  1423.            'argument_type, arg_num, arg_char, arg_varchar2, arg_date, ' ||
  1424.            'arg_rowid, arg_raw) ' ||
  1425.           'VALUES(:tag, :deferred_tran_db, :deferred_tran_id, :dblink, ' ||
  1426.            ':delivery_order, :callno, :procedure, :argument, ' ||
  1427.            ':argument_name, :argument_type, :arg_num, :arg_char, ' ||
  1428.            ':arg_varchar2, :arg_date, :arg_rowid, :arg_raw)',
  1429.         dbms_sql.v7);
  1430.       dbms_sql.bind_variable(sql_cursor, 'tag', tag);
  1431.       dbms_sql.bind_variable(sql_cursor, 'deferred_tran_db', deferred_tran_db);
  1432.       dbms_sql.bind_variable(sql_cursor, 'deferred_tran_id', deferred_tran_id);
  1433.       dbms_sql.bind_variable(sql_cursor, 'dblink', dblink);
  1434.       dbms_sql.bind_variable(sql_cursor, 'delivery_order', delivery_order);
  1435.       dbms_sql.bind_variable(sql_cursor, 'callno', callno);
  1436.       dbms_sql.bind_variable(sql_cursor, 'procedure', procedure_name);
  1437.       dbms_sql.bind_variable(sql_cursor, 'argument', arg);
  1438.       dbms_sql.bind_variable(sql_cursor, 'argument_name', arg_name);
  1439.       dbms_sql.bind_variable(sql_cursor, 'argument_type', print_type);
  1440.       dbms_sql.bind_variable(sql_cursor, 'arg_num', arg_num);
  1441.       dbms_sql.bind_variable(sql_cursor, 'arg_char', arg_char);
  1442.       dbms_sql.bind_variable(sql_cursor, 'arg_varchar2', arg_varchar2);
  1443.       dbms_sql.bind_variable(sql_cursor, 'arg_date', arg_date);
  1444.       dbms_sql.bind_variable(sql_cursor, 'arg_rowid', arg_rowid);
  1445.       dbms_sql.bind_variable(sql_cursor, 'arg_raw', arg_raw);
  1446.       dummy := dbms_sql.execute(sql_cursor);
  1447.       dbms_sql.close_cursor(sql_cursor);
  1448.     END IF;
  1449.     RETURN advance(position, offset);
  1450.   EXCEPTION WHEN others THEN
  1451.     IF dbms_sql.is_open(sql_cursor) THEN
  1452.       dbms_sql.close_cursor(sql_cursor);
  1453.     END IF;
  1454.     RAISE;
  1455.   END print_arg;
  1456.  
  1457.  
  1458.   PROCEDURE print_header(queue_name IN VARCHAR2) IS
  1459.   -- Print the header information for a deferred queue using dbms_output.
  1460.   -- Specifically, print two blank lines, queue_name with a colon, and
  1461.   --   another blank line.
  1462.   BEGIN
  1463.     dbms_output.put_line('');
  1464.     dbms_output.put_line('');
  1465.     dbms_output.put_line(queue_name || ':');
  1466.     dbms_output.put_line('');
  1467.   END print_header;
  1468.  
  1469.  
  1470.   PROCEDURE print_procedure(deferred_tran_db IN VARCHAR2,
  1471.                             deferred_tran_id IN VARCHAR2,
  1472.                             callno           IN NUMBER,
  1473.                             delivery_order   IN NUMBER,
  1474.                             dblink           IN VARCHAR2,
  1475.                             schemaname       IN VARCHAR2,
  1476.                             packagename      IN VARCHAR2,
  1477.                             procname         IN VARCHAR2,
  1478.                             argcount         IN NUMBER,
  1479.                             date_format      IN VARCHAR2,
  1480.                             table_name       IN VARCHAR2,
  1481.                             tag              IN VARCHAR2) IS
  1482.   -- The first three parameters identify a deferred remote procedure call.
  1483.   -- Print the full name of the procedure and information about each parameter
  1484.   --   using dbms_output.
  1485.   -- If table_name is not null, insert this information into the given table
  1486.   --   tagged with tag.
  1487.   -- The last printed line is blank.
  1488.   i             BINARY_INTEGER;
  1489.   offset        BINARY_INTEGER := 0; -- offset to info about overloaded proc
  1490.   fullname      VARCHAR2(98) := '"' || schemaname || '"."' || packagename ||
  1491.                                 '"."' || procname || '"';
  1492.   overload      dbms_describe.number_table;
  1493.   position      dbms_describe.number_table;
  1494.   level_no      dbms_describe.number_table;
  1495.   argument_name dbms_describe.varchar2_table;
  1496.   datatype      dbms_describe.number_table;
  1497.   default_value dbms_describe.number_table;
  1498.   in_out        dbms_describe.number_table;
  1499.   length        dbms_describe.number_table;
  1500.   precision     dbms_describe.number_table;
  1501.   scale         dbms_describe.number_table;
  1502.   radix         dbms_describe.number_table;
  1503.   spare         dbms_describe.number_table;
  1504.  
  1505.   BEGIN
  1506.     dbms_output.put_line('deferred_tran_db: ' || deferred_tran_db);
  1507.     dbms_output.put_line('deferred_tran_id: ' || deferred_tran_id);
  1508.     dbms_output.put_line('dblink: ' || dblink);
  1509.     dbms_output.put_line('delivery_order: ' || TO_CHAR(delivery_order));
  1510.     dbms_output.put_line('callno: ' || TO_CHAR(callno));
  1511.     dbms_output.put_line('procedure: ' || fullname);
  1512.     --*** describe does not support remote procedures, so ignore dblink
  1513.     dbms_describe.describe_procedure(fullname, NULL, NULL,
  1514.       overload, position, level_no, argument_name, datatype, default_value,
  1515.       in_out, length, precision, scale, radix, spare);
  1516.     offset := which_proc(overload, position, datatype, argcount, callno,
  1517.                          deferred_tran_id, deferred_tran_db);
  1518.     ---|||
  1519.     num_args := argcount;
  1520.     dbms_output.put_line('arguments: ' || num_args);
  1521.     ---|||
  1522.  
  1523.     FOR i IN 1..argcount LOOP
  1524.       offset := print_arg(i, callno, deferred_tran_id, deferred_tran_db,
  1525.                           date_format, offset, position, argument_name,
  1526.                           table_name, tag, dblink, delivery_order, fullname);
  1527.     END LOOP;
  1528.     dbms_output.put_line('');
  1529.   END print_procedure;
  1530.  
  1531.  
  1532.   --------
  1533.   -- PACKAGE EXTERNAL PROCEDURES
  1534.   --
  1535.  
  1536.  
  1537.   PROCEDURE create_unpacked_table(schema_name IN VARCHAR2 := NULL,
  1538.                                   table_name  IN VARCHAR2 := NULL) IS
  1539.   real_table_name VARCHAR2(65);
  1540.   sql_cursor      NUMBER;
  1541.   dummy           NUMBER;
  1542.  
  1543.   BEGIN
  1544.     get_unpacked_table_name(schema_name, table_name, real_table_name);
  1545.     sql_cursor := dbms_sql.open_cursor;
  1546.     dbms_sys_sql.parse_as_user(sql_cursor,
  1547.         ' CREATE TABLE ' || real_table_name || '(' ||
  1548.           ' tag              VARCHAR2(30),' ||
  1549.           ' deferred_tran_db VARCHAR2(128),' ||
  1550.           ' deferred_tran_id VARCHAR2(22),' ||
  1551.           ' dblink           VARCHAR2(128),' ||
  1552.           ' delivery_order   NUMBER,' ||
  1553.           ' callno           NUMBER,' ||
  1554.           ' procedure        VARCHAR2(98),' ||
  1555.           ' argument         NUMBER,' ||
  1556.           ' argument_name    VARCHAR2(30),' ||
  1557.           ' argument_type    VARCHAR2(8),' ||
  1558.           ' arg_num          NUMBER,' ||
  1559.           ' arg_char         CHAR(255),' ||
  1560.           ' arg_varchar2     VARCHAR2(2000),' ||
  1561.           ' arg_date         DATE,' ||
  1562.           ' arg_rowid        ROWID,' ||
  1563.           ' arg_raw          RAW(255))',
  1564.         dbms_sql.v7);
  1565.     dummy := dbms_sql.execute(sql_cursor);
  1566.     dbms_sql.close_cursor(sql_cursor);
  1567.   EXCEPTION WHEN others THEN
  1568.     IF dbms_sql.is_open(sql_cursor) THEN
  1569.       dbms_sql.close_cursor(sql_cursor);
  1570.     END IF;
  1571.     RAISE;
  1572.   END create_unpacked_table;
  1573.  
  1574.  
  1575.   PROCEDURE print_deftran(deferred_tran_id IN VARCHAR2 := NULL,
  1576.                           deferred_tran_db IN VARCHAR2 := NULL,
  1577.                           destination      IN VARCHAR2 := NULL,
  1578.                           callno           IN NUMBER,
  1579.                           date_format      IN VARCHAR2 :=
  1580.                                               'YY:MM:DD:HH24:MI:SS',
  1581.                           save_output      IN BOOLEAN := FALSE,
  1582.                           schema_name      IN VARCHAR2 := NULL,
  1583.                           table_name       IN VARCHAR2 := NULL,
  1584.                           tag              IN VARCHAR2 := NULL) IS
  1585.   save_table VARCHAR2(65);
  1586.   CURSOR c IS
  1587.     SELECT t.deferred_tran_db, t.deferred_tran_id, t.delivery_order,
  1588.            c.callno, c.schemaname, c.packagename, c.procname,
  1589.            c.argcount, d.dblink
  1590.       FROM deftran t, deftrandest d, defcall c
  1591.       WHERE d.deferred_tran_db = t.deferred_tran_db
  1592.         AND d.deferred_tran_id = t.deferred_tran_id
  1593.         AND c.deferred_tran_db = t.deferred_tran_db
  1594.         AND c.deferred_tran_id = t.deferred_tran_id
  1595.         AND print_deftran.callno = c.callno
  1596.         AND (print_deftran.deferred_tran_db IS NULL OR
  1597.              print_deftran.deferred_tran_db = t.deferred_tran_db)
  1598.         AND (print_deftran.deferred_tran_id IS NULL OR
  1599.              print_deftran.deferred_tran_id = t.deferred_tran_id)
  1600.         AND (destination IS NULL OR destination = d.dblink)
  1601.       -- order results for deterministic testing
  1602.       ORDER BY t.deferred_tran_db, t.delivery_order, t.deferred_tran_id,
  1603.         c.callno;
  1604.  
  1605.   BEGIN
  1606.     IF save_output THEN
  1607.       get_unpacked_table_name(schema_name, table_name, save_table);
  1608.     ELSE
  1609.       save_table := '';
  1610.     END IF;
  1611.     print_header('deftran');
  1612.     FOR r IN c LOOP
  1613.       print_procedure(r.deferred_tran_db, r.deferred_tran_id, r.callno,
  1614.                       r.delivery_order, r.dblink, r.schemaname, r.packagename,
  1615.                       r.procname, r.argcount, date_format, save_table, tag);
  1616.     END LOOP;
  1617.   END print_deftran;
  1618.  
  1619.  
  1620.   PROCEDURE print_deferror(deferred_tran_id IN VARCHAR2 := NULL,
  1621.                            deferred_tran_db IN VARCHAR2 := NULL,
  1622.                            callno           IN NUMBER,
  1623.                            date_format      IN VARCHAR2 :=
  1624.                                               'YY:MM:DD:HH24:MI:SS',
  1625.                            save_output      IN BOOLEAN := FALSE,
  1626.                            schema_name      IN VARCHAR2 := NULL,
  1627.                            table_name       IN VARCHAR2 := NULL,
  1628.                            tag              IN VARCHAR2 := NULL) IS
  1629.   save_table VARCHAR2(65);
  1630.   CURSOR c IS
  1631.     SELECT t.deferred_tran_db, t.deferred_tran_id, t.delivery_order, c.callno,
  1632.            c.schemaname, c.packagename, c.procname, c.argcount
  1633.       FROM deftran t, deferror e, defcall c
  1634.       WHERE e.deferred_tran_db = t.deferred_tran_db
  1635.         AND e.deferred_tran_id = t.deferred_tran_id
  1636.         AND c.deferred_tran_db = t.deferred_tran_db
  1637.         AND c.deferred_tran_id = t.deferred_tran_id
  1638.         AND print_deferror.callno = c.callno
  1639.         AND (print_deferror.deferred_tran_db IS NULL OR
  1640.              print_deferror.deferred_tran_db = e.deferred_tran_db)
  1641.         AND (print_deferror.deferred_tran_id IS NULL OR
  1642.              print_deferror.deferred_tran_id = e.deferred_tran_id)
  1643.       -- order results for deterministic testing
  1644.       ORDER BY t.deferred_tran_db, t.delivery_order, t.deferred_tran_id,
  1645.         c.callno;
  1646.  
  1647.   BEGIN
  1648.     IF save_output THEN
  1649.       get_unpacked_table_name(schema_name, table_name, save_table);
  1650.     ELSE
  1651.       save_table := '';
  1652.     END IF;
  1653.     print_header('deferror');
  1654.     FOR r IN c LOOP
  1655.       print_procedure(r.deferred_tran_db, r.deferred_tran_id, r.callno,
  1656.                       r.delivery_order, local_node, r.schemaname,
  1657.                       r.packagename, r.procname, r.argcount, date_format,
  1658.                       save_table, tag);
  1659.     END LOOP;
  1660.   END print_deferror;
  1661.  
  1662.   FUNCTION return_name (idx IN BINARY_INTEGER) RETURN VARCHAR2 IS
  1663.   BEGIN
  1664.     IF idx > num_args or idx < 1 THEN
  1665.       RETURN NULL;
  1666.     ELSE
  1667.       RETURN arg_names(idx);
  1668.     END IF;
  1669.   END return_name;
  1670.  
  1671.   FUNCTION return_type (idx IN BINARY_INTEGER) RETURN VARCHAR2 IS
  1672.   BEGIN
  1673.     IF idx > num_args or idx < 1 THEN
  1674.       RETURN NULL;
  1675.     ELSE
  1676.       RETURN arg_types(idx);
  1677.     END IF;
  1678.   END return_type;
  1679.  
  1680.   FUNCTION return_value (idx IN BINARY_INTEGER) RETURN VARCHAR2 IS
  1681.   BEGIN
  1682.     IF idx > num_args or idx < 1 THEN
  1683.       RETURN NULL;
  1684.     ELSE
  1685.       RETURN arg_values(idx);
  1686.     END IF;
  1687.   END return_value;
  1688.  
  1689. -------------
  1690. -- PACKAGE INITIALIZATION
  1691. BEGIN
  1692.   SELECT global_name INTO local_node FROM global_name;
  1693. END dbms_defer_print;
  1694. /
  1695. show errors
  1696.  
  1697.  
  1698. -----------------------------------------------------------------------
  1699. --- Create the tables and views needed to store deferred call arguments
  1700. -----------------------------------------------------------------------
  1701. --- Create a table to store the deferred call arguments
  1702. drop table SYS.DEFCALLARGS;
  1703. create table SYS.DEFCALLARGS
  1704. (tag              VARCHAR2(30),      --- tag to identify the argument
  1705.  deferred_tran_db VARCHAR2(128),     --- reference to deferror and deftran
  1706.  deferred_tran_id VARCHAR2(22),
  1707.  dblink           VARCHAR2(128),     
  1708.  delivery_order   NUMBER,
  1709.  callno           NUMBER,
  1710.  procedure        VARCHAR2(98),      --- called procedure
  1711.  argument         NUMBER,            --- argument number
  1712.  argument_name    VARCHAR2(30),     
  1713.  argument_type    VARCHAR2(8),
  1714.  arg_num          NUMBER,            --- only one of the following columns
  1715.  arg_char         CHAR(255),         --- will contain valid information
  1716.  arg_varchar2     VARCHAR2(2000),    --- based on the type of the argument
  1717.  arg_date         DATE,
  1718.  arg_rowid        ROWID,
  1719.  arg_raw          RAW(255))
  1720. /
  1721. comment on table SYS.DEFCALLARGS is
  1722. 'Store the deferred call arguments for dbms_defer_print package'
  1723. /
  1724. comment on column SYS.DEFCALLARGS.TAG is
  1725. 'String to identify a call and its argument'
  1726. /
  1727. comment on column SYS.DEFCALLARGS.DEFERRED_TRAN_DB is
  1728. 'Database originating or copying the RPC'
  1729. /
  1730. comment on column SYS.DEFCALLARGS.DEFERRED_TRAN_ID is
  1731. 'Transaction ID originating the RPC'
  1732. /
  1733. comment on column SYS.DEFCALLARGS.DBLINK is
  1734. 'database link used to address the destination'
  1735. /
  1736. comment on column SYS.DEFCALLARGS.DELIVERY_ORDER is
  1737. 'SCN of originating or copying transaction'
  1738. /
  1739. comment on column SYS.DEFCALLARGS.CALLNO is
  1740. 'Unique Id of the call'
  1741. /
  1742. comment on column SYS.DEFCALLARGS.PROCEDURE is
  1743. 'The called procedure'
  1744. /
  1745. comment on column SYS.DEFCALLARGS.ARGUMENT is
  1746. 'The order of the argument in the parameter list'
  1747. /
  1748. comment on column SYS.DEFCALLARGS.ARGUMENT_NAME is
  1749. 'The symbolic name of the argument'
  1750. /
  1751. comment on column SYS.DEFCALLARGS.ARGUMENT_TYPE is
  1752. 'The argument type'
  1753. /
  1754. comment on column SYS.DEFCALLARGS.ARG_NUM is
  1755. 'If the argument type is a number then this is the value of the number'
  1756. /
  1757. comment on column SYS.DEFCALLARGS.ARG_CHAR is
  1758. 'If the argument type is a char then this is the value of the char'
  1759. /
  1760. comment on column SYS.DEFCALLARGS.ARG_VARCHAR2 is
  1761. 'If the argument type is a varchar2 then this is the value of the varchar2'
  1762. /
  1763. comment on column SYS.DEFCALLARGS.ARG_DATE is
  1764. 'If the argument type is a date then this is the value of the date'
  1765. /
  1766. comment on column SYS.DEFCALLARGS.ARG_ROWID is
  1767. 'If the argument type is a rowid then this is the value of the rowid'
  1768. /
  1769. comment on column SYS.DEFCALLARGS.ARG_RAW is
  1770. 'If the argument type is a raw then this is the value of the raw'
  1771. /
  1772.  
  1773.  
  1774. --- View to extract information from defcallargs in a readable format
  1775. create or replace view DBA_ADMINARGUMENTS
  1776.   (TAG, PROC, ARG_NO, ARG_NAME, ARG_TYPE, ARG_VAL)
  1777. as
  1778. select
  1779.   tag,
  1780.   procedure,
  1781.   argument,
  1782.   argument_name,
  1783.   argument_type,
  1784.   DECODE(argument_type, 'NUMBER', TO_CHAR(arg_num),
  1785.     DECODE(argument_type, 'CHAR', arg_char,
  1786.       DECODE(argument_type, 'VARCHAR2', arg_varchar2,
  1787.         DECODE(argument_type, 'DATE', TO_CHAR(arg_date, 'DD-MON-RR HH24:MI:SS'),
  1788.           DECODE(argument_type, 'ROWID', ROWIDTOCHAR(arg_rowid),
  1789.             DECODE(argument_type, 'RAW', NULL))))))
  1790. from defcallargs
  1791. /
  1792. comment on table DBA_ADMINARGUMENTS is
  1793. 'Present the information from DBA_ADMINARGUMENTS is a easily readable format'
  1794. /
  1795. comment on column DBA_ADMINARGUMENTS.TAG is
  1796. 'String to identify a call and its arguments'
  1797. /
  1798. comment on column DBA_ADMINARGUMENTS.PROC is
  1799. 'The called procedure'
  1800. /
  1801. comment on column DBA_ADMINARGUMENTS.ARG_NO is
  1802. 'The order of the argument in the parameter list'
  1803. /
  1804. comment on column DBA_ADMINARGUMENTS.ARG_NAME is
  1805. 'The symbolic name of the argument'
  1806. /
  1807. comment on column DBA_ADMINARGUMENTS.ARG_TYPE is
  1808. 'The argument type'
  1809. /
  1810. comment on column DBA_ADMINARGUMENTS.ARG_VAL is
  1811. 'The value of the argument converted to a varchar2'
  1812. /
  1813.  
  1814. commit
  1815. /
  1816.