home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume30 / oraperl-v2 / part04 / Hints < prev    next >
Encoding:
Text File  |  1992-07-06  |  4.5 KB  |  149 lines

  1. This file contains hints and tips about Oraperl, dealing with problems which
  2. have arisen in the past.
  3.  
  4. The topics dealt with are the following:
  5.  
  6.     Memory Usage
  7.     Building on a Convex machine
  8.     Building on Dual Universe machines
  9.     Building with Perl v3
  10.     Using Bind Variables
  11.     Building with Oracle v5
  12.  
  13.  
  14. Memory Usage
  15. ============
  16.  
  17. With versions of Perl prior to 4.034, there is a memory leak when
  18. repeated calls to &ora_fetch() are made within a while() loop.
  19.  
  20. The correct solution is to upgrade to 4.034. However, if that is
  21. not possible for some reason, there is a workaround.
  22.  
  23. Create a Perl subroutine which returns a row from a database and
  24. call this instead. So instead of
  25.  
  26.     while (@data = &ora_fetch($csr))
  27.     {
  28.         ...
  29.     }
  30.  
  31. you should use something like this:
  32.  
  33.     sub getrow
  34.     {
  35.         local($csr) = @_;
  36.         local(@data);
  37.  
  38.         @data = &ora_fetch($csr);
  39.     }
  40.  
  41.     ...
  42.  
  43.     while (@data = &getrow($csr))
  44.     {
  45.         ...
  46.     }
  47.  
  48.  
  49. Building on a Convex machine
  50. ============================
  51.  
  52. Comment out the definition of STRTOUL in the Makefile.
  53.  
  54.  
  55. Building on Dual Universe machines
  56. ==================================
  57.  
  58. This was reported on a Pyramid machine, but I think it applies to most (if
  59. not all) dual-universe systems (Sequent, Gould, etc).  Although packages
  60. built in one universe will run correctly in the other, hybrids (packages
  61. built partly in one universe and partly in the other) will not work
  62. properly in either. On the Pyramid, the symptom was that output was being
  63. lost, although a debugging trace showed that the program was working
  64. properly.
  65.  
  66. Since Oracle specifies that it is to be installed in the ATT universe, you
  67. must also compile Perl and Oraperl (and the curses usersubs, if you are
  68. building Coraperl) in the ATT universe to allow them to be linked together.
  69.  
  70.  
  71. Building with Perl v3
  72. =====================
  73.  
  74. Ideally, get hold of v4. However, if you have to work with v3, uncomment
  75. the definition of STR_2MORTAL in the Makefile. Note also the section on
  76. memory usage above.
  77.  
  78.  
  79. Using Bind Variables
  80. ====================
  81.  
  82. The support for bind variables does not reflect the full potential of Pro*C.
  83.  
  84. Firstly, bind variables may only be numeric; named bind variables are not
  85. supported. They must run in sequence from 1. (This is to make it easy for
  86. &ora_bind() to check that it has received the correct number of parameters.)
  87.  
  88. Secondly, they may only be used to modify values within the SQL statement,
  89. not field or table names. Thus
  90.  
  91.     insert into telno values (:1, :2)
  92.  
  93. is valid, but
  94.  
  95.     select * from telno order by :1
  96.  
  97. is not. This made the interaction between &ora_open() and &ora_bind() simpler,
  98. but if it's a serious restriction for you let me know, and I'll look into
  99. extending it. (Of course, there's nothing to stop you doing:
  100.  
  101.     $order_by = "name";
  102.     &ora_open($lda, "select * from telno order by $order_by");
  103.  
  104. so I don't think it should be too big a problem.)
  105.  
  106.  
  107. Building with Oracle v5
  108. =======================
  109.  
  110. [ This information was originally in a separate file, Oracle-v5)    ]
  111. [ You will have to adapt this slightly as the Makefile has changed. ]
  112.  
  113. The Makefile includes library definitions which are suitable for Oracle v6
  114. on an Encore Multimax running UMAX V. I do not have access to any other
  115. configuration to test Oraperl.
  116.  
  117. Oraperl just links to the Oracle Pro*C libraries in the same way as any
  118. other Pro*C program, so give it the same libraries as you would give one
  119. of your own programs. See your Pro*C manual or example programs for details.
  120.  
  121. However, two people sent me their modified Makefiles for Oracle v5. Since
  122. they are different in effect, not only in presentation, I assume that the
  123. directory structure of Oracle varies between systems. The two setups I was
  124. sent are reproduced below. Maybe one of them will be suitable for your
  125. system if mine isn't.
  126.  
  127. First method - this assumes that the libraries live under $ORACLE_HOME/c/libs
  128. and $ORACLE_HOME/rdbms/libs, as well as requiring an additional .o file.
  129.  
  130. > ORALIBS    = -locic -loracle -lupi -losd -losn -loracle \
  131. >    $(ORACLE_HOME)/rdbms/libs/osntab.o -lutt -losd -losn -lclib0
  132. >
  133. > LDFLAGS    = -L$(ORACLE_HOME)/c/libs -L$(ORACLE_HOME)/rdbms/libs
  134. >
  135. > oraperl: $(SRC)/uperl.o $(OBJS)
  136. >     $(CC) -o oraperl $(LDFLAGS) $(SRC)/uperl.o $(OBJS) $(ORALIBS) $(LIBS)
  137.  
  138. Second method - much simpler. Only seems to require the first two libraries
  139. (libocic and liboracle) of the previous method, but this time they live under
  140. $ORACLE_HOME/pro.
  141.  
  142. > OTHERLIBS    =
  143. > CLIBS        = $(OTHERLIBS)
  144. > OCILIB    = $(ORACLE_HOME)/pro/libocic.a
  145. > NETLIBS    =
  146. > ORALIBS    = $(ORACLE_HOME)/pro/liboracle.a
  147.  
  148. Thanks to Mark Adams and Norman Frech for their help.
  149.