home *** CD-ROM | disk | FTP | other *** search
- #!./oraperl
- #
- # mkdb.pl
- #
- # Sample oraperl program to create a new database and load data into it.
- #
- # Author: Kevin Stock
- # Date: 5th August 1991
- #
-
- # let's see what oraperl is doing when it executes this
-
- $ora_debug = 136;
-
- $CREATE = "create table tryit (name char(10), ext number(3))";
- $INSERT = "insert into tryit values (:1, :2)";
- $LIST = "select * from tryit order by name";
- $DROP = "drop table tryit";
-
- format top =
- Name Ext
- ==== ===
- .
-
- format STDOUT =
- @<<<<<<<<< @>>
- $name, $ext
- .
-
- die ("You should use oraperl, not perl\n") unless defined &ora_login;
-
- # create the database
-
- $lda = &ora_login("t", "kstock", "kstock") || die $ora_errstr;
- $csr = &ora_open($lda, $CREATE) || die $ora_errstr;
- do ora_close($csr) || die $ora_errstr;
-
- # put some data into it
-
- $csr = &ora_open($lda, $INSERT) || die $ora_errstr;
- while (<DATA>)
- {
- m/([a-z]+):([0-9]+)/;
- do ora_bind($csr, $1, $2);
- }
- do ora_close($csr) || die $ora_errstr;
-
- # list the result
-
- $csr = &ora_open($lda, $LIST) || die $ora_errstr;
- while (($name, $ext) = &ora_fetch($csr))
- {
- write;
- }
- do ora_close($csr) || die $ora_errstr;
-
- # remove the database
-
- $csr = &ora_open($lda, $DROP) || die $ora_errstr;
- do ora_close($csr) || die $ora_errstr;
- do ora_logoff($lda) || die $ora_errstr;
- __END__
- david:225
- angela:208
- bruno:302
- albert:294
- julia:292
- alison:206
- arnold:305
- larry:424
- catherine:201
- randall:306
- susan:307
-