home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / programming / oracle7 7.2 / DB / UTIL72 / PISTUB.SQL < prev    next >
Encoding:
Text File  |  1995-05-18  |  7.6 KB  |  201 lines

  1. rem
  2. rem $Header: pistub.sql 7020100.1 94/09/28 15:14:21 cli Generic<base> $
  3. rem
  4. Rem  Copyright (c) 1991 by Oracle Corporation
  5. Rem    NAME
  6. Rem      pistub.sql - subprogram stub generator
  7. Rem    DESCRIPTION
  8. Rem      equivalent to v7$pls:[qa]pstub.pls
  9. Rem    MODIFIED   (MM/DD/YY)
  10. Rem     pshaw      10/21/92 -  modify script for bug 131187 
  11. Rem     gclossma   09/08/92 -  allow null dbname in cursor in pstub 
  12. Rem     gclossma   08/05/92 -  impl pstub in terms of pistub 
  13. Rem     gclossma   07/14/92 -  pstubT: add constraints to CHARs; bigger pkgs 
  14. Rem     gclossma   06/22/92 -  pstubt: gen stubs into table PSTUBTBL 
  15. Rem     gclossma   05/08/92 -  simplify; check buffer lengths 
  16. Rem     gclossma   04/10/92 -  gen CHAR stead of VARCHAR2 for sqlforms3 for v6 
  17. Rem     ahong      03/24/92 -  add s_notInPackage 
  18. Rem     ahong      03/13/92 -  rpc 
  19. Rem     ahong      03/10/92 -  fix func stub 
  20. Rem     ahong      02/26/92 -  fix subptxt 
  21. Rem     ahong      01/07/92 -  icd for DESCRIBE
  22. Rem    pdufour    01/03/92 -  remove connect internal and add drop package
  23. Rem     gclossma   11/27/91 -  Creation
  24.  
  25.  
  26.  
  27. -- pstub:      procedure returning stub text of a subprogram
  28. --       In:  pname - subprogram name
  29. --        subname - NULL or member name of package pname
  30. --        uname - user name, NULL or '' to mean current user
  31. --              flags - string,  '6' for v6 compatibility mode in which
  32. --            'CHAR' is gen'd in place of 'VARCHAR2' in stubs
  33. --       Out:
  34. --        stubSpec - null if subprogram is a top level proc/func
  35. --               else contain package spec
  36. --        stubText - contains stub body
  37. --                '$$$ s_subpNotFound' -> subprog not found; stubSpec empty
  38. --            '$$$ s_notInPackage' -> cannot find subname in pname
  39. --            '$$$ s_stubTooLong' -> stub text too long; stubSpec empty
  40. --            '$$$ s_logic' -> logic error; stubSpec empty
  41. --            '$$$ s_defaultVal' -> default parameter values exist;
  42. --                     stubSpec empty
  43. --            '$$$ s_other' -> other failure
  44.  
  45. -- pstub calls diutil.pstub:
  46. --       In:  pname - subprogram name
  47. --        subname - NULL or member name of package pname
  48. --        uname - user name, NULL or '' to mean current user
  49. --        dbname - database name, null or '' for current
  50. --        dbowner - database owner, null or '' for current
  51. --              flags - string,  '6' for v6 compatibility mode in which
  52. --            'CHAR' is gen'd in place of 'VARCHAR2' in stubs
  53. --       Out:
  54. --        stubSpec - null if subprogram is a top level proc/func
  55. --               else contain package spec
  56. --        stubText - contains stub body
  57. --        status - error code, see package DIUTIL
  58.  
  59. -- NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
  60. -- NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
  61. -- NOTE: you must be connected "internal" (as user SYS) to run this script.
  62. -- NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
  63. -- NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
  64.  
  65.  
  66. ---------------------------------------------------------------------
  67.  
  68. -- pstubt:    generates stub text into table PSTUBTBL
  69. --       In:  pname - program (package or subprogram) name
  70. --        uname - user name, NULL or '' to mean current user
  71. --        dbname - unused, for compatitility with plsv1 psdglu()
  72. --              flags - string,  '6' for v6 compatibility mode in which
  73. --            'CHAR' is gen'd in place of 'VARCHAR2' in stubs
  74. --       Out:
  75. --        rc - an OUT varchar2 of length 40.  It is set as follows:
  76. --            'PKG' if package stub was successfully generated to table
  77. --            'SUB' if subprogram stub was successfully gen'd to table
  78. --                '$$$ s_subpNotFound' -> program not found
  79. --            '$$$ s_notInPackage' -> cannot find subname in pname
  80. --            '$$$ s_stubTooLong' -> stub text too long
  81. --            '$$$ s_logic' -> logic error
  82. --            '$$$ s_defaultVal' -> default parameter values exist;
  83. --            '$$$ s_other' -> other failure
  84.  
  85. /* PSTUBT: stores generated stubs in rows of table PSTUBTBL */
  86. drop procedure sys.pstubt;
  87. create procedure sys.pstubt (pname varchar2, uname varchar2, dbname varchar2,
  88.                  flags varchar2, rc OUT varchar2) is
  89.   status diutil.ub4 := 0;
  90.   lutype varchar2(10);
  91. begin
  92.   rc := '';
  93.   diutil.pstub(pname, '', uname, dbname, '', status, flags, lutype);
  94.   if (status <> diutil.s_ok and status <> diutil.s_defaultVal) then
  95.     if (status = diutil.s_subpNotFound) then
  96.         rc := '$$$ s_subpNotFound';
  97.     elsif (status = diutil.s_stubTooLong) then
  98.             rc := '$$$ s_stubTooLong';
  99.         elsif (status = diutil.s_logic) then
  100.             rc := '$$$ s_logic';
  101.         elsif (status = diutil.s_notInPackage) then
  102.             rc := '$$$ s_notInPackage';
  103.     elsif (status = diutil.s_notv6Compat) then
  104.         rc := '$$$ s_notv6Compat';
  105.     else rc := '$$$ s_other';
  106.     end if;
  107.   else rc := lutype;
  108.   end if;
  109. end;
  110. /
  111. grant execute on pstubt to public;
  112.  
  113. -- pstub is older interface, now implemented in terms of pstubt
  114.  
  115. drop procedure sys.pstub;
  116. create procedure sys.pstub(pname varchar2, uname varchar2,
  117.             stubSpec in out varchar2, stubText in out varchar2,
  118.             flags varchar2 := '6') is
  119.   rc varchar2(40);
  120.   ty varchar2(5);
  121.   cursor tub (una varchar2, dbna varchar2, luna varchar2, luty varchar2) is
  122.     select line from sys.pstubtbl 
  123.     where (una is null or username = una) and
  124.           (dbna is null or dbname = dbna) and
  125.           lun = luna and lutype = luty
  126.     order by lineno;
  127. begin -- main
  128.   sys.pstubt(pname, uname, '', flags, rc);
  129.   if rc like '$$$%' then stubText := rc; return; end if;
  130.   if not (rc = 'PKG' or rc = 'SUB') 
  131.     then stubText := '$$$ other'; return; 
  132.   end if;
  133.   stubSpec := '';
  134.   stubText := '';
  135.   if rc = 'PKG' then
  136.     for s in tub(uname, '', pname, 'PKS') loop
  137.       stubSpec := stubSpec || s.line;
  138.     end loop;
  139.   end if;
  140.   if rc = 'PKG' then ty := 'PKB'; else ty := 'SUB'; end if;
  141.   for s in tub(uname, '', pname, ty) loop
  142.     stubText := stubText || s.line;
  143.   end loop;
  144. end;
  145. /
  146. grant execute on pstub to public;
  147.  
  148.  
  149. ---------------------------------------------------------------------
  150. --
  151. --  subptxt2: returns the text of a subprogram source (DESCRIBE).
  152. --     In: name - package or toplevel proc/func name;
  153. --          subname - non-null to specify proc/func in package <name>.
  154. --        usr - user name
  155. --        dbname - database name, null or '' for current
  156. --        dbowner - database owner, null or '' for current
  157. --    Out:  subprogram text in txt
  158. --        '$$$ s_subpNotFound' -> subprog not found; txt empty
  159. --        '$$$ s_stubTooLong' -> stub text too long; txt empty
  160. --        '$$$ s_logic' -> logic error; txt empty
  161. --        '$$$ s_notInPackage' -> cannot find subname in package <name>
  162. --        '$$$ s_other' -> other failure
  163.  
  164. drop procedure sys.subptxt2;
  165. create procedure sys.subptxt2(name varchar2, subname varchar2, usr varchar2,
  166.                  dbname varchar2, dbowner varchar2,
  167.                              txt in out varchar2) is
  168. status diutil.ub4;
  169.  
  170. begin -- main
  171.     diutil.subptxt(name, subname, usr, dbname, dbowner, txt, status);
  172.     if (status <> diutil.s_ok) then
  173.     if (status = diutil.s_subpNotFound) then
  174.         txt := '$$$ s_subpNotFound';
  175.     elsif (status = diutil.s_stubTooLong) then
  176.             txt := '$$$ s_stubTooLong';
  177.         elsif (status = diutil.s_logic) then
  178.             txt := '$$$ s_logic';
  179.         elsif (status = diutil.s_notInPackage) then
  180.             txt := '$$$ s_notInPackage';
  181.     else txt := '$$$ s_other';
  182.     end if;
  183.     end if;
  184. end subptxt2;
  185. /
  186.  
  187. ---------------------------------------------------------------------
  188.  
  189. -- subptxt - similar to subptxt2, but w/o dbname and dbowner
  190.  
  191.  
  192. drop procedure sys.subptxt;
  193. create procedure sys.subptxt(name varchar2, subname varchar2, usr varchar2,
  194.                              txt in out varchar2) is
  195. begin
  196.     subptxt2(name, subname, usr, null, null, txt);
  197. end;
  198. /
  199. grant execute on subptxt to public;
  200.  
  201.