home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-01-06 | 41.4 KB | 1,494 lines |
- Newsgroups: comp.sources.misc
- From: kstock@encore.com (Kevin Stock)
- Subject: v27i067: oraperl - Extensions to Perl to access Oracle databases, Patch05
- Message-ID: <1992Jan6.160506.8880@sparky.imd.sterling.com>
- X-Md4-Signature: 42382a781566e670d17d5e98a1e8ded1
- Date: Mon, 6 Jan 1992 16:05:06 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: kstock@encore.com (Kevin Stock)
- Posting-number: Volume 27, Issue 67
- Archive-name: oraperl/patch05
- Environment: Perl, Oracle, Pro*C, optionally Curses
- Patch-To: oraperl: Volume 18, Issue 10
-
- This is Patch 05 for Oraperl, a set of usersubs which allow Perl to
- access Oracle databases. You need Perl (v3.0.27 or better) and Oracle
- (including the Oracle Call Interface) to build Oraperl. If you can
- build Larry's Curseperl, then you can also buld Coraperl, which is
- Oraperl with Curses.
-
- Oraperl appeared in comp.sources.misc as follows:
-
- v18i010 original
- v20i097 patch 01
- v22i058 patch 02
- v25i035, 036 patch 03
- v26i036 patch 04
-
-
- Details of Patch 05
- -------------------
-
- Additions
- ---------
- Christian Holzbaur (christian@ai.univie.ac.at) sent me routines for
- commit and rollback, which I have added to the distribution. If you
- don't know what commit and rollback do, try out the commit.pl script.
- Thanks, Christian.
-
- A new sample script, bind.pl, shows how ora_bind() and ora_fetch()
- can be combined to to perform a simple but effiecient table lookup.
-
- A new function, ora_titles() has been added to allow a program to
- determine the titles of the columns fetched. See the sql script for
- an example of how this may be used.
-
- General
- -------
- Improved error checking for ora_close and ora_logoff. In particular,
- note that if these functions fail, the specified csr or lda is now
- _not_ released, so you can still use them if you want to try to fix
- the problem.
-
- What to do
- ----------
- Unshar this message somewhere convenient. This will create the
- following files:
-
- Patch05 the patch
- bind.pl sample script for ora_bind
- commit.pl sample script for commit and rollback
-
- Apply the patch, then recompile.
-
- Please let me know if you have any problems with this patch or with
- Oraperl in general. Any bug fixes, additions, suggestions or other
- comments are welcome.
-
-
- Kevin
- kstock@encore.com, kstock@gouldfr.encore.fr
-
-
- #!/bin/sh
- # This is a shell archive (produced by shar 3.49)
- # To extract the files from this archive, save it to a file, remove
- # everything above the "!/bin/sh" line above, and type "sh file_name".
- #
- # made 01/02/1992 15:41 UTC by kstock@mmcompta
- # Source directory /usr/local/src/cmd/oraperl
- #
- # existing files will NOT be overwritten unless -c is specified
- #
- # This shar contains:
- # length mode name
- # ------ ---------- ------------------------------------------
- # 34887 -rw-r--r-- Patch05
- # 520 -rw-r--r-- bind.pl
- # 1266 -rw-r--r-- commit.pl
- #
- # ============= Patch05 ==============
- if test -f 'Patch05' -a X"$1" != X"-c"; then
- echo 'x - skipping Patch05 (File already exists)'
- else
- echo 'x - extracting Patch05 (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'Patch05' &&
- Xdiff -c orig/patchlevel.h ./patchlevel.h
- XPrereq: 4
- X*** orig/patchlevel.h Thu Jan 2 16:22:08 1992
- X--- ./patchlevel.h Fri Dec 27 16:30:02 1991
- X***************
- X*** 1,3 ****
- X /* patchlevel.h */
- X
- X! #define PATCHLEVEL 4
- X--- 1,3 ----
- X /* patchlevel.h */
- X
- X! #define PATCHLEVEL 5
- Xdiff -c orig/CHANGES ./CHANGES
- X*** orig/CHANGES Thu Jan 2 16:22:08 1992
- X--- ./CHANGES Thu Jan 2 14:29:27 1992
- X***************
- X*** 38,40 ****
- X--- 38,47 ----
- X Added a strtoul() function
- X Separated the clean and realclean/clobber targets
- X Cleaned up a few bits and pieces - shouldn't make any difference
- X+
- X+ Patch 05
- X+ ========
- X+ Added functions for commit and rollback, plus commit.pl to demonstrate them
- X+ Added a function to get the column titles, modified sql command to use it
- X+ Added the bind.pl script
- X+ Improved error handling for ora_close and ora_logoff
- Xdiff -c orig/Makefile ./Makefile
- X*** orig/Makefile Thu Jan 2 16:22:09 1992
- X--- ./Makefile Thu Jan 2 15:41:11 1992
- X***************
- X*** 49,55 ****
- X HDRS = patchlevel.h orafns.h
- X DEFS = $(STRTOL) $(PUTENV) $(STR_2MORTAL)
- X
- X! CFLAGS = $(DEBUG) -I$(SRC) $(GLOBINCS) $(LOCINCS) $(DEFS) -O
- X
- X oraperl: $(SRC)/uperl.o $(OOBJS)
- X $(CC) -o oraperl $(SRC)/uperl.o $(OOBJS) \
- X--- 49,55 ----
- X HDRS = patchlevel.h orafns.h
- X DEFS = $(STRTOL) $(PUTENV) $(STR_2MORTAL)
- X
- X! CFLAGS = $(DEBUG) -I$(SRC) $(GLOBINCS) $(LOCINCS) $(DEFS) # -O
- X
- X oraperl: $(SRC)/uperl.o $(OOBJS)
- X $(CC) -o oraperl $(SRC)/uperl.o $(OOBJS) \
- X***************
- X*** 59,67 ****
- X $(CC) -o coraperl $(SRC)/uperl.o $(COBJS) $(SRC)/usub/curses.o \
- X -lm $(OCILIB) $(NETLIBS) $(ORALIBS) $(CLIBS) $(LIBS) $(CURSELIB)
- X
- X! cusersub.o: usersub.c
- X @rm -f cusersub.c
- X ln usersub.c cusersub.c
- X $(CC) -c $(CFLAGS) -DCURSES cusersub.c
- X
- X oracle.c: $(SRC)/usub/mus oracle.mus
- X--- 59,69 ----
- X $(CC) -o coraperl $(SRC)/uperl.o $(COBJS) $(SRC)/usub/curses.o \
- X -lm $(OCILIB) $(NETLIBS) $(ORALIBS) $(CLIBS) $(LIBS) $(CURSELIB)
- X
- X! cusersub.c: usersub.c
- X @rm -f cusersub.c
- X ln usersub.c cusersub.c
- X+
- X+ cusersub.o: cusersub.c
- X $(CC) -c $(CFLAGS) -DCURSES cusersub.c
- X
- X oracle.c: $(SRC)/usub/mus oracle.mus
- Xdiff -c orig/README ./README
- X*** orig/README Thu Jan 2 16:22:09 1992
- X--- ./README Fri Dec 27 16:50:07 1991
- X***************
- X*** 20,26 ****
- X DEBUG -DDEBUGGING, -DPERL_DEBUGGING or leave blank;
- X see orafns.h for an explanation
- X PUTENV \
- X! STRTOL +- system dependent - see Makefile for details
- X STR_2MORTAL /
- X
- X As well as oraperl, you can also type "make coraperl" to create a version
- X--- 20,26 ----
- X DEBUG -DDEBUGGING, -DPERL_DEBUGGING or leave blank;
- X see orafns.h for an explanation
- X PUTENV \
- X! STRTOUL +- system dependent - see Makefile for details
- X STR_2MORTAL /
- X
- X As well as oraperl, you can also type "make coraperl" to create a version
- X***************
- X*** 49,54 ****
- X--- 49,56 ----
- X strtoul.c for systems which don't have strtoul(3)
- X
- X Examples
- X+ bind.pl use of ora_bind and ora_fetch for table lookup
- X+ commit.pl using commit and rollback
- X debug-p tests to see if debugging is available
- X ex.pl simple example of Oraperl functions
- X mkdb.pl more extensive example, using curses if available
- Xdiff -c orig/ex.pl ./ex.pl
- X*** orig/ex.pl Thu Jan 2 16:19:13 1992
- X--- ./ex.pl Thu Nov 28 16:18:43 1991
- X***************
- X*** 1,4 ****
- X! format top =
- X Name Phone
- X ==== =====
- X .
- X--- 1,4 ----
- X! format STDOUT_TOP =
- X Name Phone
- X ==== =====
- X .
- Xdiff -c orig/mkdb.pl ./mkdb.pl
- X*** orig/mkdb.pl Thu Jan 2 16:22:10 1992
- X--- ./mkdb.pl Fri Dec 27 16:27:24 1991
- X***************
- X*** 13,18 ****
- X--- 13,21 ----
- X # make sure that we really are running (c)oraperl
- X die ("You should use oraperl, not perl\n") unless defined &ora_login;
- X
- X+ # get debugging & error codes
- X+ require('oraperl.ph');
- X+
- X # Arrange to use curses functions if they're available.
- X # (This is just showing off)
- X
- X***************
- X*** 59,67 ****
- X eval <<'____END_OF_PLAIN_STUFF';
- X
- X $curses = 0;
- X! $ora_debug = 8;
- X
- X! format top =
- X Name Ext
- X ==== ===
- X .
- X--- 62,70 ----
- X eval <<'____END_OF_PLAIN_STUFF';
- X
- X $curses = 0;
- X! $ora_debug = $ODBG_EXEC | $ODBG_MALLOC;
- X
- X! format STDOUT_TOP =
- X Name Ext
- X ==== ===
- X .
- X***************
- X*** 99,107 ****
- X do after();
- X }
- X
- X- # get debugging & error codes
- X- require('oraperl.ph');
- X-
- X # set these as strings to make the code more readable
- X $CREATE = "create table tryit (name char(10), ext number(3))";
- X $INSERT = "insert into tryit values (:1, :2)";
- X--- 102,107 ----
- X***************
- X*** 111,117 ****
- X
- X # create the database
- X
- X! $lda = &ora_login("t", "kstock", "kstock") || die $ora_errstr;
- X &ora_do($lda, $CREATE) || die $ora_errstr;
- X
- X # put some data into it
- X--- 111,117 ----
- X
- X # create the database
- X
- X! $lda = &ora_login('t', 'kstock', 'kstock') || die $ora_errstr;
- X &ora_do($lda, $CREATE) || die $ora_errstr;
- X
- X # put some data into it
- X***************
- X*** 151,155 ****
- X angela:208
- X larry:424
- X catherine:201
- X! randall:306
- X arnold:305
- X--- 151,155 ----
- X angela:208
- X larry:424
- X catherine:201
- X! randal:306
- X arnold:305
- Xdiff -c orig/oracle.mus ./oracle.mus
- X*** orig/oracle.mus Thu Jan 2 16:22:10 1992
- X--- ./oracle.mus Thu Jan 2 11:00:31 1992
- X***************
- X*** 29,39 ****
- X--- 29,42 ----
- X US_ora_version,
- X US_ora_login,
- X US_ora_open,
- X+ US_ora_titles,
- X US_ora_bind,
- X US_ora_fetch,
- X US_ora_close,
- X US_ora_do,
- X US_ora_logoff,
- X+ US_ora_commit,
- X+ US_ora_rollback,
- X };
- X
- X static int usersub();
- X***************
- X*** 60,70 ****
- X--- 63,76 ----
- X make_usub("ora_version", US_ora_version, usersub, filename);
- X make_usub("ora_login", US_ora_login, usersub, filename);
- X make_usub("ora_open", US_ora_open, usersub, filename);
- X+ make_usub("ora_titles", US_ora_titles, usersub, filename);
- X make_usub("ora_bind", US_ora_bind, usersub, filename);
- X make_usub("ora_fetch", US_ora_fetch, usersub, filename);
- X make_usub("ora_close", US_ora_close, usersub, filename);
- X make_usub("ora_do", US_ora_do, usersub, filename);
- X make_usub("ora_logoff", US_ora_logoff, usersub, filename);
- X+ make_usub("ora_commit", US_ora_commit, usersub, filename);
- X+ make_usub("ora_rollback", US_ora_rollback,usersub, filename);
- X };
- X
- X
- X***************
- X*** 95,100 ****
- X--- 101,124 ----
- X I char * stmt
- X END
- X
- X+ case US_ora_titles:
- X+ if (items != 1) {
- X+ fatal("Usage: @array = &ora_titles($csr)");
- X+ } else {
- X+ char *csr = (char *) str_get(st[1]);
- X+ int retval;
- X+
- X+ retval = ora_titles(csr);
- X+ astore(stack, sp + retval, Nullstr);
- X+ st = stack->ary_array + sp;
- X+ for (i = 0 ; i < retval ; i++) {
- X+ tmps = ora_result[i];
- X+ st[i] = str_2mortal(str_make(tmps, strlen(tmps)));
- X+ }
- X+ return sp + retval - 1;
- X+ }
- X+ /* NOTREACHED */
- X+
- X case US_ora_fetch:
- X if (items != 1) {
- X if (curcsv->wantarray)
- X***************
- X*** 166,171 ****
- X--- 190,203 ----
- X END
- X
- X CASE char * ora_logoff
- X+ I char * lda
- X+ END
- X+
- X+ CASE char * ora_commit
- X+ I char * lda
- X+ END
- X+
- X+ CASE char * ora_rollback
- X I char * lda
- X END
- X
- Xdiff -c orig/orafns.c ./orafns.c
- X*** orig/orafns.c Thu Jan 2 16:22:11 1992
- X--- ./orafns.c Thu Jan 2 11:52:39 1992
- X***************
- X*** 252,259 ****
- X DEBUG(8, 1, (fprintf(stderr,
- X "ora_open(%s, \"%s\")\n", lda_s, stmt)));
- X DEBUG(32, 0, (fprintf(stderr,
- X! "ora_open: string \"%s\" converted to lda %#lx\n",
- X! lda_s, lda)));
- X
- X if (check_lda(lda) == 0)
- X {
- X--- 252,258 ----
- X DEBUG(8, 1, (fprintf(stderr,
- X "ora_open(%s, \"%s\")\n", lda_s, stmt)));
- X DEBUG(32, 0, (fprintf(stderr,
- X! "ora_open: string \"%s\" converted to lda %#lx\n", lda_s, lda)));
- X
- X if (check_lda(lda) == 0)
- X {
- X***************
- X*** 336,341 ****
- X--- 335,352 ----
- X "ora_open: got rcode array %d items %d bytes at %#lx\n",
- X i, i * sizeof(short), (long) csr->rcode)));
- X
- X+ if ((csr->len = (short *) malloc(i * sizeof(short))) == NULL)
- X+ {
- X+ (void) ora_dropcursor(csr);
- X+ DEBUG((8 | 128), -1, (fputs(
- X+ "ora_open: out of memory\n", stderr)));
- X+ ora_errno = ORAP_NOMEM;
- X+ return((char *) NULL);
- X+ }
- X+ DEBUG(128, 0, (fprintf(stderr,
- X+ "ora_open: got len array %d items %d bytes at %#lx\n",
- X+ i, i * sizeof(short), (long) csr->len)));
- X+
- X csr->nfields = i;
- X
- X for (i = 0 ; i < csr->nfields ; i++)
- X***************
- X*** 360,365 ****
- X--- 371,377 ----
- X odefin(csr->csr, i + 1, csr->data[i], dsize + 1, 5, 0,
- X (short *) 0, (char *) 0, 0, 0, (short *) 0,
- X &(csr->rcode[i]));
- X+ csr->len[i] = dsize;
- X }
- X }
- X else
- X***************
- X*** 379,384 ****
- X--- 391,458 ----
- X }
- X
- X
- X+ /* ora_titles(csr)
- X+ *
- X+ * returns the column headers for the query referenced by csr
- X+ */
- X+
- X+ int ora_titles(csr_s)
- X+ char *csr_s;
- X+ {
- X+ int i;
- X+ short len;
- X+ struct cursor *csr = (struct cursor *)strtoul(csr_s, (char **) NULL, 0);
- X+
- X+ DEBUG(8, 1, (fprintf(stderr, "ora_titles(%s)\n", csr_s)));
- X+ DEBUG(32, 0, (fprintf(stderr,
- X+ "ora_titles: string \"%s\" converted to csr %#lx\n", csr_s, csr)));
- X+
- X+ if (check_csr(csr) == 0)
- X+ {
- X+ DEBUG(8, -1, (fputs("ora_titles: not a csr\n", stderr)));
- X+ ora_errno = ORAP_INVCSR;
- X+ return(0);
- X+ }
- X+ else if (csr->nfields == 0)
- X+ {
- X+ DEBUG(8, -1, (fputs("ora_titles: nothing to return\n",stderr)));
- X+ ora_errno = ORAP_NODATA;
- X+ return(0);
- X+ }
- X+
- X+ for (i = 0 ; i < csr->nfields ; i++)
- X+ {
- X+ len = csr->len[i];
- X+ oname(csr->csr, i + 1, (char *) -1, (short *) -1,
- X+ csr->data[i], &len);
- X+ csr->data[i][csr->len[i]] = '\0';
- X+ }
- X+
- X+ #ifdef DEBUGGING
- X+ /* NOTE: use the DEBUG macro for printing even here in case
- X+ * the debug output format is changed later
- X+ */
- X+
- X+ if (ora_debug & 8)
- X+ {
- X+ DEBUG(8, 0, (fputs("ora_titles: returning titles:\n", stderr)));
- X+ for (i = 0 ; i < csr->nfields ; i++)
- X+ {
- X+ DEBUG(8, 0, (fprintf(stderr,
- X+ "ora_titles: field %4d title \"%s\"\n",
- X+ i, csr->data[i])));
- X+ }
- X+ }
- X+ #endif
- X+
- X+ DEBUG(8, -1, (fprintf(stderr,
- X+ "ora_titles: returning %d items\n", csr->nfields)));
- X+ ora_result = csr->data;
- X+ ora_errno = 0;
- X+ return(csr->nfields);
- X+ }
- X+
- X+
- X /* ora_fetch(csr)
- X *
- X * returns the next set of data from the cursor
- X***************
- X*** 390,400 ****
- X int i;
- X struct cursor *csr = (struct cursor *)strtoul(csr_s, (char **) NULL, 0);
- X
- X! DEBUG(8, 1, (fprintf(stderr,
- X! "ora_fetch(%s)\n", csr_s)));
- X DEBUG(32, 0, (fprintf(stderr,
- X! "ora_fetch: string \"%s\" converted to csr %#lx\n",
- X! csr_s, csr)));
- X
- X if (check_csr(csr) == 0)
- X {
- X--- 464,472 ----
- X int i;
- X struct cursor *csr = (struct cursor *)strtoul(csr_s, (char **) NULL, 0);
- X
- X! DEBUG(8, 1, (fprintf(stderr, "ora_fetch(%s)\n", csr_s)));
- X DEBUG(32, 0, (fprintf(stderr,
- X! "ora_fetch: string \"%s\" converted to csr %#lx\n", csr_s, csr)));
- X
- X if (check_csr(csr) == 0)
- X {
- X***************
- X*** 464,469 ****
- X--- 536,542 ----
- X }
- X }
- X #endif
- X+
- X DEBUG(8, -1, (fprintf(stderr,
- X "ora_fetch: returning %d items\n", csr->nfields)));
- X ora_result = csr->data;
- X***************
- X*** 546,553 ****
- X {
- X char *csr_s;
- X
- X! DEBUG(8, 1, (fprintf(stderr,
- X! "ora_do(%s, \"%s\")\n", lda_s, stmt)));
- X
- X if ((csr_s = ora_open(lda_s, stmt)) == NULL)
- X {
- X--- 619,625 ----
- X {
- X char *csr_s;
- X
- X! DEBUG(8, 1, (fprintf(stderr, "ora_do(%s, \"%s\")\n", lda_s, stmt)));
- X
- X if ((csr_s = ora_open(lda_s, stmt)) == NULL)
- X {
- X***************
- X*** 582,589 ****
- X
- X DEBUG(8, 1, (fprintf(stderr, "ora_close(%s)\n", csr_s)));
- X DEBUG(32, 0, (fprintf(stderr,
- X! "ora_close: string \"%s\" converted to csr %#lx\n",
- X! csr_s, csr)));
- X
- X if (check_csr(csr) == 0)
- X {
- X--- 654,660 ----
- X
- X DEBUG(8, 1, (fprintf(stderr, "ora_close(%s)\n", csr_s)));
- X DEBUG(32, 0, (fprintf(stderr,
- X! "ora_close: string \"%s\" converted to csr %#lx\n", csr_s, csr)));
- X
- X if (check_csr(csr) == 0)
- X {
- X***************
- X*** 592,603 ****
- X return(NULL);
- X }
- X
- X! oclose(csr->csr);
- X! ora_errno = csr->csr->csrrc;
- X! (void) ora_dropcursor(csr);
- X!
- X! DEBUG(8, -1, (fputs("ora_close: returning OK\n", stderr)));
- X! return(OK);
- X }
- X
- X
- X--- 663,680 ----
- X return(NULL);
- X }
- X
- X! if (oclose(csr->csr) != 0)
- X! {
- X! ora_errno = csr->csr->csrrc;
- X! DEBUG(8, -1, (fputs("ora_close: oclose failed\n", stderr)));
- X! return(NULL);
- X! }
- X! else
- X! {
- X! (void) ora_dropcursor(csr);
- X! DEBUG(8, -1, (fputs("ora_close: returning OK\n", stderr)));
- X! return(OK);
- X! }
- X }
- X
- X
- X***************
- X*** 613,620 ****
- X
- X DEBUG(8, 1, (fprintf(stderr, "ora_logoff(%s)\n", lda_s)));
- X DEBUG(32, 0, (fprintf(stderr,
- X! "ora_logoff: string \"%s\" converted to lda %#lx\n",
- X! lda_s, lda)));
- X
- X if (check_lda(lda) == 0)
- X {
- X--- 690,696 ----
- X
- X DEBUG(8, 1, (fprintf(stderr, "ora_logoff(%s)\n", lda_s)));
- X DEBUG(32, 0, (fprintf(stderr,
- X! "ora_logoff: string \"%s\" converted to lda %#lx\n", lda_s, lda)));
- X
- X if (check_lda(lda) == 0)
- X {
- X***************
- X*** 623,632 ****
- X return(NULL);
- X }
- X
- X! ologof(lda->csr);
- X! ora_errno = lda->csr->csrrc;
- X! (void) ora_droplda(lda);
- X
- X! DEBUG(8, -1, (fputs("ora_logoff: returning OK\n", stderr)));
- X! return(OK);
- X }
- X--- 699,784 ----
- X return(NULL);
- X }
- X
- X! if (ologof(lda->csr) != 0)
- X! {
- X! ora_errno = lda->csr->csrrc;
- X! DEBUG(8, -1, (fputs("ora_logoff: ologoff failed\n", stderr)));
- X! return(NULL);
- X! }
- X! else
- X! {
- X! (void) ora_droplda(lda);
- X! DEBUG(8, -1, (fputs("ora_logoff: returning OK\n", stderr)));
- X! return(OK);
- X! }
- X! }
- X!
- X!
- X! /* ora_commit(lda)
- X! *
- X! * Commits all pending transactions on the specified lda.
- X! */
- X!
- X! char *ora_commit(lda_s)
- X! char *lda_s;
- X! {
- X! struct cursor *lda = (struct cursor *)strtoul(lda_s, (char **) NULL, 0);
- X!
- X! DEBUG(8, 1, (fprintf(stderr, "ora_commit(%s)\n", lda_s)));
- X! DEBUG(32, 0, (fprintf(stderr,
- X! "ora_commit: string \"%s\" converted to lda %#lx\n", lda_s, lda)));
- X!
- X! if (check_lda(lda) == 0)
- X! {
- X! DEBUG(8, -1, (fputs("ora_commit: not an lda\n", stderr)));
- X! ora_errno = ORAP_INVLDA;
- X! return(NULL);
- X! }
- X!
- X! if (ocom(lda->csr) != 0)
- X! {
- X! ora_errno = lda->csr->csrrc;
- X! DEBUG(8, -1, (fputs("ora_commit: ocom failed\n", stderr)));
- X! return(NULL);
- X! }
- X! else
- X! {
- X! DEBUG(8, -1, (fputs("ora_commit: returning OK\n", stderr)));
- X! return(OK);
- X! }
- X! }
- X!
- X!
- X! /* ora_rollback(lda)
- X! *
- X! * rollbacks all pending transactions on the specified lda.
- X! */
- X!
- X! char *ora_rollback(lda_s)
- X! char *lda_s;
- X! {
- X! struct cursor *lda = (struct cursor *)strtoul(lda_s, (char **) NULL, 0);
- X
- X! DEBUG(8, 1, (fprintf(stderr, "ora_rollback(%s)\n", lda_s)));
- X! DEBUG(32, 0, (fprintf(stderr,
- X! "ora_rollback: string \"%s\" converted to lda %#lx\n", lda_s, lda)));
- X!
- X! if (check_lda(lda) == 0)
- X! {
- X! DEBUG(8, -1, (fputs("ora_rollback: not an lda\n", stderr)));
- X! ora_errno = ORAP_INVLDA;
- X! return(NULL);
- X! }
- X!
- X! if (orol(lda->csr) != 0)
- X! {
- X! ora_errno = lda->csr->csrrc;
- X! DEBUG(8, -1, (fputs("ora_rollback: orol failed\n", stderr)));
- X! return(NULL);
- X! }
- X! else
- X! {
- X! DEBUG(8, -1, (fputs("ora_rollback: returning OK\n", stderr)));
- X! return(OK);
- X! }
- X }
- Xdiff -c orig/orafns.h ./orafns.h
- X*** orig/orafns.h Thu Jan 2 16:22:11 1992
- X--- ./orafns.h Thu Jan 2 11:07:44 1992
- X***************
- X*** 18,27 ****
- X *ora_open(),
- X *ora_close(),
- X *ora_do(),
- X! *ora_logoff();
- X
- X int ora_bind(),
- X! ora_fetch();
- X
- X
- X /* These functions are internal to the system, not for public consumption */
- X--- 18,30 ----
- X *ora_open(),
- X *ora_close(),
- X *ora_do(),
- X! *ora_logoff(),
- X! *ora_commit(),
- X! *ora_rollback();
- X
- X int ora_bind(),
- X! ora_fetch(),
- X! ora_titles();
- X
- X
- X /* These functions are internal to the system, not for public consumption */
- X***************
- X*** 70,76 ****
- X struct csrdef *csr;
- X char *hda, /* used if this cursor is an lda */
- X **data; /* used to receive database contents */
- X! short *rcode; /* used to receive fetch error codes */
- X int nfields, /* number of fields to retrieve */
- X varfields; /* number of modifiable variables */
- X struct cursor *next; /* list pointer */
- X--- 73,80 ----
- X struct csrdef *csr;
- X char *hda, /* used if this cursor is an lda */
- X **data; /* used to receive database contents */
- X! short *rcode, /* used to receive fetch error codes */
- X! *len; /* used to receive field lengths */
- X int nfields, /* number of fields to retrieve */
- X varfields; /* number of modifiable variables */
- X struct cursor *next; /* list pointer */
- Xdiff -c orig/oraperl.1 ./oraperl.1
- X*** orig/oraperl.1 Thu Jan 2 16:22:15 1992
- X--- ./oraperl.1 Thu Jan 2 11:03:36 1992
- X***************
- X*** 12,19 ****
- X--- 12,22 ----
- X
- X $lda = &ora_login($database, $name, $password)
- X $csr = &ora_open($lda, $stmt)
- X+ &ora_titles($csr)
- X &ora_bind($csr, $var, ...)
- X &ora_fetch($csr)
- X+ &ora_commit($lda)
- X+ &ora_rollback($lda)
- X &ora_close($csr)
- X &ora_do($lda, $stmt)
- X &ora_logoff($lda)
- X***************
- X*** 54,59 ****
- X--- 57,70 ----
- X is only suitable for statements which do not return data
- X or contain substitution variables.
- X
- X+ A program may determine the field titles of an executed query
- X+ by calling the \fIora_titles\fP.
- X+ This function takes a single parameter,
- X+ a statement identifier (obtained from \fIora_open\fP)
- X+ indicating the query for which the titles are required.
- X+ The titles are returned as an array of strings,
- X+ one for each column.
- X+
- X If the SQL statement contains substitution variables
- X \fIora_bind\fP is used to assign values to them.
- X This function takes a statement identifier (obtained from \fIora_open\fP)
- X***************
- X*** 77,82 ****
- X--- 88,99 ----
- X Every \fIora_open\fP call should have a corresponding \fIora_close\fP,
- X even if it did not return any data.
- X
- X+ Modifications to a database
- X+ may be committed or rolled back
- X+ using the \fIora_commit\fP and \fIora_rollback\fP functions.
- X+ These functions take a single parameter,
- X+ a login identifier obtained from \fIora_login\fP.
- X+
- X When the program no longer needs to access a given database,
- X the login identifier should be released using the \fIora_logoff\fP function.
- X This function returns the string \fBOK\fP.
- X***************
- X*** 191,201 ****
- X are supported.
- X .SH NOTES
- X In keeping with the philosophy of \fIPerl\fP,
- X! there is no pre-defined limit to the number of simultaneous logins
- X or SQL statements which may be active,
- X nor to the number of data fields which may be returned by a query.
- X The only limits are those imposed by the amount of memory available,
- X or by \fIOracle\fP.
- X
- X Debugging option \fB32\fP only reports internal string/numeric translations,
- X not those performed on the data retrieved from the database.
- X--- 208,226 ----
- X are supported.
- X .SH NOTES
- X In keeping with the philosophy of \fIPerl\fP,
- X! there is no pre\-defined limit to the number of simultaneous logins
- X or SQL statements which may be active,
- X nor to the number of data fields which may be returned by a query.
- X The only limits are those imposed by the amount of memory available,
- X or by \fIOracle\fP.
- X+
- X+ Since the parameter to \fIora_commit\fP and \fIora_rollback\fP
- X+ is a login identifier and not a statement identifier,
- X+ \fIall\fP work associated with that login identifier
- X+ will be commited or rolled back simultaneously.
- X+ If you wish to be able to commit or roll back individual statements
- X+ you will have to call \fIora_login\fP multiple times
- X+ to obtain a login identifier for each statement.
- X
- X Debugging option \fB32\fP only reports internal string/numeric translations,
- X not those performed on the data retrieved from the database.
- Xdiff -c orig/oraperl.doc ./oraperl.doc
- X*** orig/oraperl.doc Thu Jan 2 16:22:05 1992
- X--- ./oraperl.doc Thu Jan 2 11:03:45 1992
- X***************
- X*** 27,33 ****
- X because it requires fixed addresses to be specified for receipt of data.
- X A new interface was therefore created for \fBOraperl\fP.
- X
- X! The interface follows the idiom of the following seven tasks:
- X
- X .in +5
- X .ta .4i 4.4i
- X--- 27,33 ----
- X because it requires fixed addresses to be specified for receipt of data.
- X A new interface was therefore created for \fBOraperl\fP.
- X
- X! The interface follows the idiom of the following tasks:
- X
- X .in +5
- X .ta .4i 4.4i
- X***************
- X*** 34,46 ****
- X .nf
- X \fBTask Interface\fP
- X
- X! \fB1\fP log in to the database \fIora_login\fP
- X! \fB2\fP open a stream for an SQL statement \fIora_open\fP
- X! \fB3\fP modify the statement \fIora_bind\fP
- X! \fB4\fP get the data \fIora_fetch\fP
- X! \fB5\fP close the stream \fIora_close\fP
- X! \fB6\fP execute an SQL statement \fIora_do\fP
- X! \fB7\fP log off of the database \fIora_logoff\fP
- X .fi
- X .in -5
- X
- X--- 34,50 ----
- X .nf
- X \fBTask Interface\fP
- X
- X! \fB\01\fP log in to the database \fIora_login\fP
- X! \fB\02\fP open a stream for an SQL statement \fIora_open\fP
- X! \fB\03\fP retrieve the column names \fIora_titles\fP
- X! \fB\04\fP modify the statement \fIora_bind\fP
- X! \fB\05\fP get the data \fIora_fetch\fP
- X! \fB\06\fP close the stream \fIora_close\fP
- X! \fB\07\fP execute an SQL statement \fIora_do\fP
- X! \fB\08\fP commit the work done to a database \fIora_commit\fP
- X! \fB\09\fP roll back the work done to a database \fIora_rollback\fP
- X! \fB10\fP log off of the database \fIora_logoff\fP
- X!
- X .fi
- X .in -5
- X
- X***************
- X*** 57,62 ****
- X--- 61,74 ----
- X and returns an identifier to the user
- X to be supplied as a parameter to future function calls.
- X
- X+ \fBOraperl\fP's notion of a cursor is an extension of the \fIOCI\fP cursor.
- X+ An \fIOraperl\fP cursor contains an \fIOCI\fP cursor
- X+ together with other fields as required.
- X+ A cursor returned by the \fIora_login\fP function
- X+ also includes a host data area.
- X+ A cursor returned by the \fIora_open\fP function
- X+ also includes space for returned data and other status information.
- X+
- X A set of functions (not directly accessible to the user)
- X deals with the allocation and release of cursors.
- X
- X***************
- X*** 117,122 ****
- X--- 129,141 ----
- X It returns the address of the \fIcsr\fP.
- X
- X
- X+ \fBora_titles(csr)\fP
- X+
- X+ Returnes an array contain the field names associated with the query
- X+ identified by \fIcsr\fP.
- X+ This may be useful in programs which allow the user to specify a query.
- X+
- X+
- X \fBora_bind(csr, var, ...)\fP
- X
- X Binds the specified \fIvar\fPs to the substitution variables
- X***************
- X*** 154,159 ****
- X--- 173,190 ----
- X of the \fIcsr\fP used.
- X It is suitable for statements which do not return any data
- X and which do not contain any substitution variables.
- X+
- X+
- X+ \fBora_commit(lda)\fP
- X+
- X+ Calls \fBOCI\ ocom\fP to commit the work done under the given \fIlda\fP.
- X+ The string \fBOK\fP is returned.
- X+
- X+
- X+ \fBora_rollback(lda)\fP
- X+
- X+ Calls \fBOCI\ orol\fP to roll back the work done under the given \fIlda\fP.
- X+ The string \fBOK\fP is returned.
- X
- X
- X \fBora_logoff(lda)\fP
- Xdiff -c orig/oraperl.ph ./oraperl.ph
- X*** orig/oraperl.ph Thu Jan 2 16:19:32 1992
- X--- ./oraperl.ph Fri Dec 27 16:03:04 1991
- X***************
- X*** 1,6 ****
- X # oraperl.ph
- X #
- X! # Various defines which may be useful in oraperl programs
- X #
- X # Author: Kevin Stock
- X # Date: 28th October 1991
- X--- 1,6 ----
- X # oraperl.ph
- X #
- X! # Various constants which may be useful in oraperl programs
- X #
- X # Author: Kevin Stock
- X # Date: 28th October 1991
- Xdiff -c orig/oraperl.ref ./oraperl.ref
- X*** orig/oraperl.ref Thu Jan 2 16:22:05 1992
- X--- ./oraperl.ref Thu Jan 2 15:45:15 1992
- X***************
- X*** 2,54 ****
- X .\"
- X .nf
- X .\"
- X! .vs 10
- X! .ps 10
- X! \fBOraperl Quick Reference\fP
- X .ps 8
- X .sp 2
- X- .ps 10
- X \fBOraperl Functions\fP
- X! .ps 8
- X .in +2m
- X! .sp
- X .ti -2m
- X \fB&ora_version\fP
- X Displays version and copyright information for Oraperl.
- X! .sp
- X .ti -2m
- X \fB$lda = &ora_login($database, $name, $password)\fP
- X Logs into the specified database with the name and password given.
- X Returns an \fIlda\fP for use with \fIora_open()\fP.
- X! .sp
- X .ti -2m
- X \fB$csr = &ora_open($lda, $statement)\fP
- X Associates the given SQL statement in the database identified by $lda.
- X Executes it if it contains no substitution variables.
- X Returns a \fIcsr\fP for use with \fIora_fetch()\fP.
- X! .sp
- X .ti -2m
- X \fB&ora_bind($csr, $var, ...)\fP
- X Binds the given values to the substition variables in the SQL statement
- X associated with $csr, and executes the resulting statement.
- X! .sp
- X .ti -2m
- X! \fB$n = &ora_fetch($csr)\fP
- X Returns the number of fields available from the query.
- X! .sp
- X .ti -2m
- X! \fB@ary = &ora_fetch($csr)\fP
- X Retrieves the (next) output data from the statement identified by $csr.
- X! .sp
- X .ti -2m
- X \fB&ora_close($csr)\fP
- X Finishes the SQL statement identified by $csr.
- X! .sp
- X .ti -2m
- X \fB&ora_do($lda, $stmt)\fP
- X Equivalent to \fI&ora_close\fP(\fI&ora_open(...))\fP
- X for statements which have no substitution variables and do not return data.
- X! .sp
- X .ti -2m
- X \fB&ora_logoff($lda)\fP
- X Logs out of the database identified by $lda.
- X--- 2,64 ----
- X .\"
- X .nf
- X .\"
- X! .vs 8
- X .ps 8
- X+ \fBOraperl Quick Reference\fP
- X .sp 2
- X \fBOraperl Functions\fP
- X! .ps 6
- X .in +2m
- X!
- X .ti -2m
- X \fB&ora_version\fP
- X Displays version and copyright information for Oraperl.
- X!
- X .ti -2m
- X \fB$lda = &ora_login($database, $name, $password)\fP
- X Logs into the specified database with the name and password given.
- X Returns an \fIlda\fP for use with \fIora_open()\fP.
- X!
- X .ti -2m
- X \fB$csr = &ora_open($lda, $statement)\fP
- X Associates the given SQL statement in the database identified by $lda.
- X Executes it if it contains no substitution variables.
- X Returns a \fIcsr\fP for use with \fIora_fetch()\fP.
- X!
- X! .ti -2m
- X! \fB@ary = &ora_titles($csr)\fP
- X! Returns the column names associated with the query.
- X!
- X .ti -2m
- X \fB&ora_bind($csr, $var, ...)\fP
- X Binds the given values to the substition variables in the SQL statement
- X associated with $csr, and executes the resulting statement.
- X!
- X .ti -2m
- X! \fB$n = &ora_fetch($csr)\fP \fI(NB: Scalar context)\fP
- X Returns the number of fields available from the query.
- X!
- X .ti -2m
- X! \fB@ary = &ora_fetch($csr)\fP \fI(NB: Array context)\fP
- X Retrieves the (next) output data from the statement identified by $csr.
- X!
- X .ti -2m
- X \fB&ora_close($csr)\fP
- X Finishes the SQL statement identified by $csr.
- X!
- X .ti -2m
- X \fB&ora_do($lda, $stmt)\fP
- X Equivalent to \fI&ora_close\fP(\fI&ora_open(...))\fP
- X for statements which have no substitution variables and do not return data.
- X!
- X! .ti -2m
- X! \fB&ora_commit($lda)\fP
- X! Commits the work performed under the login identified by $lda.
- X!
- X! .ti -2m
- X! \fB&ora_rollback($lda)\fP
- X! Rolls back the work performed under the login identified by $lda.
- X!
- X .ti -2m
- X \fB&ora_logoff($lda)\fP
- X Logs out of the database identified by $lda.
- X***************
- X*** 56,67 ****
- X .sp 2
- X .ps 10
- X \fBOraperl Variables\fP
- X! .sp
- X .ps 8
- X .ti -2m
- X \fB$ora_errno\fP (read only)
- X Contains the error code from the last funtion call.
- X! .sp
- X .ti -2m
- X \fB$ora_errstr\fP (read only)
- X Contains the error message corresponding to $ora_errno.
- X--- 66,77 ----
- X .sp 2
- X .ps 10
- X \fBOraperl Variables\fP
- X!
- X .ps 8
- X .ti -2m
- X \fB$ora_errno\fP (read only)
- X Contains the error code from the last funtion call.
- X!
- X .ti -2m
- X \fB$ora_errstr\fP (read only)
- X Contains the error message corresponding to $ora_errno.
- Xdiff -c orig/sql ./sql
- X*** orig/sql Thu Jan 2 16:19:37 1992
- X--- ./sql Thu Jan 2 14:21:26 1992
- X***************
- X*** 2,29 ****
- X 'di';
- X 'ig00';
- X #
- X! # sql [-ddelim] username/password statement
- X #
- X # Script to run an Oracle statement from the command line.
- X # Written in response to <nirad.690285085@newdelphi> in alt.sources.wanted.
- X #
- X! # Author: Kevin Stock
- X # Date: 18th November 1991
- X #
- X
- X # $ora_debug = 8; # if you want to see what's happenning
- X
- X $, = "\t"; # default delimiter is a tab
- X $\ = "\n"; # each record terminated with newline
- X
- X! if ($ARGV[0] =~ /^-d(.*)/) # allows the delimiter to be empty
- X! {
- X! $, = $1;
- X! shift;
- X! }
- X
- X $USER = shift; # get the user name and password
- X! die "Usage: $0 sql [-ddelim] username/password statement\n" unless $#ARGV >= 0;
- X
- X # log into the database and execute the statement
- X
- X--- 2,45 ----
- X 'di';
- X 'ig00';
- X #
- X! # sql
- X #
- X # Script to run an Oracle statement from the command line.
- X # Written in response to <nirad.690285085@newdelphi> in alt.sources.wanted.
- X #
- X! # Usage:
- X! # sql [-bbase] [-ddelim] [-f|-h] [-lpage_len] username/password statement
- X! #
- X! # -b base database to use (default $ENV{'ORACLE_SID'})
- X! # -d delim specifies the field delimiter (default TAB)
- X! # -f formatted output, similar to sqlplus
- X! # -h add headers, no formatting
- X! # -l page_len lines per page, only used by -f (default 60)
- X! # username/password Oracle username and password
- X! # statement Oracle statement to be executed
- X! #
- X! # Author: Kevin Stock
- X # Date: 18th November 1991
- X #
- X
- X # $ora_debug = 8; # if you want to see what's happenning
- X
- X+ $USAGE = "[-bbase] [-ddelim] [-f|-h] [-lpage_len] username/password statement";
- X $, = "\t"; # default delimiter is a tab
- X $\ = "\n"; # each record terminated with newline
- X
- X! require 'getopts.pl'; # option parsing
- X! do Getopts('b:d:fhl:');
- X! die "$0: only one of -f and -h may be specified\n" if ($opt_f && $opt_h);
- X!
- X! $, = $opt_d if defined($opt_d); # set column delimiter
- X! $= = $opt_l if defined($opt_l); # set page length
- X! $ENV{'ORACLE_SID'} = $opt_b if defined($opt_b); # set database
- X
- X+ die "ORACLE_SID not set\n" unless defined($ENV{'ORACLE_SID'});
- X+
- X $USER = shift; # get the user name and password
- X! die "Usage: $0 $USAGE\n" unless $#ARGV >= 0;
- X
- X # log into the database and execute the statement
- X
- X***************
- X*** 32,42 ****
- X
- X # print out any information which comes back
- X
- X! if (&ora_fetch($csr) > 0) # does the statement return data?
- X {
- X while (@result = &ora_fetch($csr))
- X {
- X! print @result;
- X }
- X warn "$ora_errstr\n" if ($ora_errno != 0);
- X }
- X--- 48,85 ----
- X
- X # print out any information which comes back
- X
- X! if (($nfields = &ora_fetch($csr)) > 0) # does the statement return data?
- X {
- X+ if ($opt_f) # formatted output
- X+ {
- X+ @titles = &ora_titles($csr);
- X+ $format .= "format STDOUT_TOP =\n" . join($,, @titles) . "\n";
- X+ grep(tr//-/c, @titles);
- X+ $format .= join($,, @titles) . "\n.\n";
- X+
- X+ grep((s/^-/@/, tr/-/</), @titles);
- X+ $format .= "format STDOUT =\n" . join($,, @titles) . "\n";
- X+ foreach $i (0 .. $nfields - 1)
- X+ {
- X+ $format .= "\$result[$i],";
- X+ }
- X+ chop $format; # remove extraneous comma
- X+ $format .= "\n.\n";
- X+
- X+ eval($format);
- X+ }
- X+ elsif ($opt_h)
- X+ {
- X+ @titles = &ora_titles($csr);
- X+ grep(s/ *$//, @titles);
- X+ print @titles;
- X+ grep(tr//-/c, @titles);
- X+ print @titles;
- X+ }
- X+
- X while (@result = &ora_fetch($csr))
- X {
- X! ($opt_f) ? (write) : (print @result);
- X }
- X warn "$ora_errstr\n" if ($ora_errno != 0);
- X }
- X***************
- X*** 65,79 ****
- X .SH NAME
- X sql \- execute an Oracle SQL statement from the command line
- X .SH SYNOPSIS
- X! \fBsql\fP [\fB\-d\fP\fIdelim\fP] \fIname\fP\fB/\fP\fIpassword\fP \fIstatement\fP
- X .SH DESCRIPTION
- X .I Sql
- X connects to an Oracle database
- X using the \fIname/password\fP supplied
- X and executes the given SQL \fIstatement\fP
- X! returning the result
- X! (without column headers)
- X on its standard output.
- X Normally, fields are separated with tabs;
- X this may be changed to any desired string (\fIdelim\fP)
- X using the \fB\-d\fP flag.
- X--- 108,145 ----
- X .SH NAME
- X sql \- execute an Oracle SQL statement from the command line
- X .SH SYNOPSIS
- X! \fBsql\fP
- X! [\fB-b\fP\fIbase\fP]
- X! [\fB\-d\fP\fIdelim\fP]
- X! [\fB\-f\fP|\fB\-h\fP]
- X! [\fB-l\fP\fIpage_len\fP]
- X! \fIname\fP\fB/\fP\fIpassword\fP
- X! \fIstatement\fP
- X .SH DESCRIPTION
- X .I Sql
- X connects to an Oracle database
- X using the \fIname/password\fP supplied
- X and executes the given SQL \fIstatement\fP
- X! displaying the result
- X on its standard output.
- X+
- X+ The \fB-b\fP\fIbase\fP flag may be supplied to specify the database to be used.
- X+ If it is not given, the database specified by the environment variable
- X+ \fBORACLE_SID\fP is used.
- X+
- X+ The \fB\-f\fP and \fB\-h\fP flags may be used to modify the form of the output.
- X+ Without either flag, no field headers are printed
- X+ and fields are not padded.
- X+ With the \fB\-h\fP flag,
- X+ field headers are added to the top of the output,
- X+ but the format is otherwise unchanged.
- X+ With the \fB\-f\fP flag,
- X+ the output is formatted in a fashion similar to that used by \fIsqlplus\fP,
- X+ except that all fields are left\-justified, regardless of their data type.
- X+ Column headers are printed at the top of each page;
- X+ a page is assumed to be 60 lines long,
- X+ but this may be overridden with the \fB\-l\fP\fIpage_len\fP flag.
- X+
- X Normally, fields are separated with tabs;
- X this may be changed to any desired string (\fIdelim\fP)
- X using the \fB\-d\fP flag.
- X***************
- X*** 81,94 ****
- X The environment variable \fBORACLE_SID\fP
- X determines the Oracle database to be used.
- X .SH DIAGNOSTICS
- X! The only diagnostic generated by \fIsql\fP is a usage message.
- X However, you may also encounter
- X! error messages from Oraperl (unlikely) or Oracle (more common).
- X See the \fIOracle Error Messages and Codes Manual\fP for details.
- X .SH NOTES
- X This program is only intended for use from the command line.
- X If you use it within a shell script
- X! then you should consider rewriting it in Oraperl
- X to use Perl's text manipulation and formatting commands.
- X .SH "SEE ALSO"
- X \fISQL Language Reference Manual\fP
- X--- 147,176 ----
- X The environment variable \fBORACLE_SID\fP
- X determines the Oracle database to be used.
- X .SH DIAGNOSTICS
- X! .in +5
- X! .ti -5
- X! \fBonly one of -f and -h may be specified\fP
- X! .br
- X! the \fB-f\fP and \fB-h\fP options are mutually exclusive,
- X! but both were specified
- X!
- X! .ti -5
- X! \fBORACLE_SID not set\fP
- X! .br
- X! the \fB-b\fP\fIbase\fP option was not supplied,
- X! and the \fBORACLE_SID\fP environment variable was not set,
- X! so \fIsql\fP cannot work out which database to open
- X!
- X! .in -5
- X! The only other diagnostics generated by \fIsql\fP are usage messages,
- X! which should be self\-explanatory.
- X However, you may also encounter
- X! error messages from Oraperl (unlikely) or from Oracle (more common).
- X See the \fIOracle Error Messages and Codes Manual\fP for details.
- X .SH NOTES
- X This program is only intended for use from the command line.
- X If you use it within a shell script
- X! then you should consider rewriting your script in Oraperl
- X to use Perl's text manipulation and formatting commands.
- X .SH "SEE ALSO"
- X \fISQL Language Reference Manual\fP
- X***************
- X*** 98,103 ****
- X .SH AUTHOR
- X Kevin Stock,
- X .if t .ft C
- X! <kstock@gouldfr.encore.fr, kstock@encore.com>
- X .if t .ft P
- X .ex
- X--- 180,185 ----
- X .SH AUTHOR
- X Kevin Stock,
- X .if t .ft C
- X! <kstock@encore.com>
- X .if t .ft P
- X .ex
- SHAR_EOF
- chmod 0644 Patch05 ||
- echo 'restore of Patch05 failed'
- Wc_c="`wc -c < 'Patch05'`"
- test 34887 -eq "$Wc_c" ||
- echo 'Patch05: original size 34887, current size' "$Wc_c"
- fi
- # ============= bind.pl ==============
- if test -f 'bind.pl' -a X"$1" != X"-c"; then
- echo 'x - skipping bind.pl (File already exists)'
- else
- echo 'x - extracting bind.pl (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'bind.pl' &&
- X#!./oraperl
- X#
- X# bind.pl
- X#
- X# This shows how the ora_bind function may be used to implement a
- X# simple lookup script.
- X
- X# $ora_debug = 8;
- X
- X$lda = &ora_login('t', 'kstock', 'kstock')
- X || die $ora_errstr;
- X$csr = &ora_open($lda, 'select phone from telno where name = :1')
- X || die $ora_errstr;
- X
- Xwhile(<STDIN>)
- X{
- X chop;
- X &ora_bind($csr, $_) || die $ora_errstr;
- X
- X if (($phone) = &ora_fetch($csr))
- X {
- X print "$phone\n";
- X }
- X else
- X {
- X die $ora_errstr if $ora_errno;
- X print "unknown\n";
- X }
- X}
- X
- X&ora_close($csr);
- X&ora_logoff($lda);
- SHAR_EOF
- chmod 0644 bind.pl ||
- echo 'restore of bind.pl failed'
- Wc_c="`wc -c < 'bind.pl'`"
- test 520 -eq "$Wc_c" ||
- echo 'bind.pl: original size 520, current size' "$Wc_c"
- fi
- # ============= commit.pl ==============
- if test -f 'commit.pl' -a X"$1" != X"-c"; then
- echo 'x - skipping commit.pl (File already exists)'
- else
- echo 'x - extracting commit.pl (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'commit.pl' &&
- X#!./oraperl
- X#
- X# commit.pl
- X#
- X# Simple example of using commit and rollback.
- X
- X$lda = &ora_login('t', 'kstock', 'kstock') || die "$ora_errstr\n";
- X&ora_do($lda, 'create table primes (prime number)') || die "$ora_errstr\n";
- X
- X$csr = &ora_open($lda, 'insert into primes values(:1)') || die "$ora_errstr\n";
- Xprint 'creating table';
- Xwhile (<DATA>)
- X{
- X chop;
- X print " $_";
- X &ora_bind($csr, $_) || die "$_: $ora_errstr\n";
- X (print ' committing ', &ora_commit($lda)) if $_ == 11;
- X}
- X&ora_close($csr) || die "$ora_errstr\n";
- X
- Xprint "\n\nReading table for the first time\n\n";
- X$csr = &ora_open($lda, 'select prime from primes') || die "$ora_errstr\n";
- Xwhile (($prime) = &ora_fetch($csr))
- X{
- X print "$prime ";
- X}
- Xdie "$ora_errstr\n" if $ora_errno;
- X&ora_close($csr) || die "$ora_errstr\n";
- X
- Xprint "\n\nRolling back ", &ora_rollback($lda), "\n\n";
- X
- Xprint "Attempting to read data for the second time.\n";
- Xprint "Only values up to 11 should appear.\n\n";
- X$csr = &ora_open($lda, 'select prime from primes') || die "$ora_errstr\n";
- Xwhile (($prime) = &ora_fetch($csr))
- X{
- X print "$prime ";
- X}
- Xdie "$ora_errstr\n" if $ora_errno;
- X&ora_close($csr) || die "$ora_errstr\n";
- X
- X&ora_do($lda, 'drop table primes') || die "$ora_errstr\n";
- X&ora_logoff($lda);
- Xprint "\n"
- X__END__
- X2
- X3
- X5
- X7
- X11
- X13
- X17
- X19
- X23
- X29
- SHAR_EOF
- chmod 0644 commit.pl ||
- echo 'restore of commit.pl failed'
- Wc_c="`wc -c < 'commit.pl'`"
- test 1266 -eq "$Wc_c" ||
- echo 'commit.pl: original size 1266, current size' "$Wc_c"
- fi
- exit 0
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-