📄 dbd::oraperl.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "Oraperl 3".TH Oraperl 3 "2006-10-02" "perl v5.10.0" "User Contributed Perl Documentation".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"Oraperl \- Perl access to Oracle databases for old oraperl scripts.SH "SYNOPSIS".IX Header "SYNOPSIS".Vb 1\& eval \*(Aquse Oraperl; 1;\*(Aq || die $@ if $] >= 5; # ADD THIS LINE TO OLD SCRIPTS\&\& $lda = &ora_login($system_id, $name, $password)\& $csr = &ora_open($lda, $stmt [, $cache])\& &ora_bind($csr, $var, ...)\& &ora_fetch($csr [, $trunc])\& &ora_close($csr)\& &ora_logoff($lda)\&\& &ora_do($lda, $stmt)\&\& &ora_titles($csr)\& &ora_lengths($csr)\& &ora_types($csr)\& &ora_commit($lda)\& &ora_rollback($lda)\& &ora_autocommit($lda, $on_off)\& &ora_version()\&\& $ora_cache\& $ora_long\& $ora_trunc\& $ora_errno\& $ora_errstr\& $ora_verno\&\& $ora_debug.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"Oraperl is an extension to Perl which allows access to Oracle databases..PPThe original oraperl was a Perl 4 binary with Oracle \s-1OCI\s0 compiled into it.The Perl 5 Oraperl module described here is distributed with DBD::Oracle(a database driver what operates within \s-1DBI\s0) and adds an extra layer over\&\s-1DBI\s0 method calls.The Oraperl module should only be used to allow existing Perl 4 oraperl scriptsto run with minimal changes; any new development should use \s-1DBI\s0 directly..PPThe functions which make up this extension are described in thefollowing sections. All functions return a false or undefined (in thePerl sense) value to indicate failure. You do not need to understandthe references to \s-1OCI\s0 in these descriptions. They are here to helpthose who wish to extend the routines or to port them to new machines..PPThe text in this document is largely unchanged from the original Perl4oraperl manual written by Kevin Stock <kstock@auspex.fr>. Any commentsspecific to the DBD::Oracle Oraperl emulation are prefixed by \fB\s-1DBD:\s0\fR.See the DBD::Oracle and \s-1DBI\s0 manuals for more information..PP\&\fB\s-1DBD:\s0\fR In order to make the oraperl function definitions available inperl5 you need to arrange to 'use' the Oraperl.pm module in each fileor package which uses them. You can do this by simply adding \f(CW\*(C`use\ Oraperl;\*(C'\fR in each file or package. If you need to make the scripts workwith both the perl4 oraperl and perl5 you should add add the followingtext instead:.PP.Vb 1\& eval \*(Aquse Oraperl; 1;\*(Aq || die $@ if $] >= 5;.Ve.Sh "Principal Functions".IX Subsection "Principal Functions"The main functions for database access are &\fIora_login()\fR, &\fIora_open()\fR,&\fIora_bind()\fR, &\fIora_fetch()\fR, &\fIora_close()\fR, &\fIora_do()\fR and &\fIora_logoff()\fR..IP "\(bu" 2ora_login.Sp.Vb 1\& $lda = &ora_login($system_id, $username, $password).Ve.SpIn order to access information held within an Oracle database, aprogram must first log in to it by calling the &\fIora_login()\fR function.This function is called with three parameters, the system \s-1ID\s0 (seebelow) of the Oracle database to be used, and the Oracle username andpassword. The value returned is a login identifier (actually an OracleLogin Data Area) referred to below as \f(CW$lda\fR..SpMultiple logins may be active simultaneously. This allows a simplemechanism for correlating or transferring data between databases..SpMost Oracle programs (for example, SQL*Plus or SQL*Forms) examine theenvironment variable \s-1ORACLE_SID\s0 or \s-1TWO_TASK\s0 to determine which databaseto connect to. In an environment which uses several differentdatabases, it is easy to make a mistake, and attempt to run a programon the wrong one. Also, it is cumbersome to create a program whichworks with more than one database simultaneously. Therefore, Oraperlrequires the system \s-1ID\s0 to be passed as a parameter. However, if thesystem \s-1ID\s0 parameter is an empty string then oracle will use theexisting value of \s-1ORACLE_SID\s0 or \s-1TWO_TASK\s0 in the usual manner..SpExample:.Sp.Vb 1\& $lda = &ora_login(\*(Aqpersonnel\*(Aq, \*(Aqscott\*(Aq, \*(Aqtiger\*(Aq) || die $ora_errstr;.Ve.SpThis function is equivalent to the \s-1OCI\s0 olon and orlon functions..Sp\&\fB\s-1DBD:\s0\fR note that a name is assumed to be a \s-1TNS\s0 alias if it does notappear as the name of a \s-1SID\s0 in /etc/oratab or /var/opt/oracle/oratab.See the code in Oracle.pm for the full logic of database name handling..Sp\&\fB\s-1DBD:\s0\fR Since the returned \f(CW$lda\fR is a Perl5 reference the database loginidentifier is now automatically released if \f(CW$lda\fR is overwritten or goesout of scope..IP "\(bu" 2ora_open.Sp.Vb 1\& $csr = &ora_open($lda, $statement [, $cache]).Ve.SpTo specify an \s-1SQL\s0 statement to be executed, the program must call the&\fIora_open()\fR function. This function takes at least two parameters: alogin identifier (obtained from &\fIora_login()\fR) and the \s-1SQL\s0 statement tobe executed. An optional third parameter specifies the size of the rowcache to be used for a \s-1SELECT\s0 statement. The value returned from&\fIora_open()\fR is a statement identifier (actually an \s-1ORACLE\s0 Cursor)referred to below as \f(CW$csr\fR..SpIf the row cache size is not specified, a default size isused. As distributed, the default is five rows, but thismay have been changed at your installation (see the&\fIora_version()\fR function and \f(CW$ora_cache\fR variable below)..SpExamples:.Sp.Vb 1\& $csr = &ora_open($lda, \*(Aqselect ename, sal from emp order by ename\*(Aq, 10);\&\& $csr = &ora_open($lda, \*(Aqinsert into dept values(:1, :2, :3)\*(Aq);.Ve.SpThis function is equivalent to the \s-1OCI\s0 oopen and oparse functions. Forstatements which do not contain substitution variables (see the sectionSubstitution Variables below), it also uses of the oexec function. For\&\s-1SELECT\s0 statements, it also makes use of the odescr and odefin functionsto allocate memory for the values to be returned from the database..IP "\(bu" 2ora_bind.Sp.Vb 1\& &ora_bind($csr, $var, ...).Ve.SpIf an \s-1SQL\s0 statement contains substitution variables (see the sectionSubstitution Variables below), &\fIora_bind()\fR is used to assign actualvalues to them. This function takes a statement identifier (obtainedfrom &\fIora_open()\fR) as its first parameter, followed by as manyparameters as are required by the statement..SpExample:.Sp.Vb 1\& &ora_bind($csr, 50, \*(Aqmanagement\*(Aq, \*(AqParis\*(Aq);.Ve.SpThis function is equivalent to the \s-1OCI\s0 obndrn and oexec statements..SpThe \s-1OCI\s0 obndrn function does not allow empty strings to be bound. Asdistributed, \f(CW$ora_bind\fR therefore replaces empty strings with a singlespace. However, a compilation option allows this substitution to besuppressed, causing &\fIora_bind()\fR to fail. The output from the&\fIora_version()\fR function specifies which is the case at your installation..IP "\(bu" 2ora_fetch.Sp.Vb 1\& $nfields = &ora_fetch($csr)\&\& @data = &ora_fetch($csr [, $trunc]).Ve.SpThe &\fIora_fetch()\fR function is used in conjunction with a \s-1SQL\s0 \s-1SELECT\s0statement to retrieve information from a database. This function takesone mandatory parameter, a statement identifier (obtained from&\fIora_open()\fR)..SpUsed in a scalar context, the function returns the number of fieldsreturned by the query but no data is actually fetched. This may beuseful in a program which allows a user to enter a statement interactively..SpExample:.Sp.Vb 1\& $nfields = &ora_fetch($csr);.Ve.SpUsed in an array context, the value returned is an array containing thedata, one element per field. Note that this will not work as expected:.Sp.Vb 1\& @data = &ora_fetch($csr) || die "..."; # WRONG.Ve.SpThe || forces a scalar context so ora_fetch returns the number of fields..SpAn optional second parameter may be supplied to indicate whether thetruncation of a \s-1LONG\s0 or \s-1LONG\s0 \s-1RAW\s0 field is to be permitted (non-zero) orconsidered an error (zero). If this parameter is not specified, thevalue of the global variable \f(CW$ora_trunc\fR is used instead. Truncation ofother datatypes is always considered a error..Sp\&\fB\s-1DBD:\s0\fR The optional second parameter to ora_fetch is not supported.A \s-1DBI\s0 usage error will be generated if a second parameter is supplied.Use the global variable \f(CW$ora_trunc\fR instead. Also note that theexperimental \s-1DBI\s0 blob_read method can be used to retrieve a long:.Sp.Vb 1\& $csr\->blob_read($field, $offset, $len [, \e$dest, $destoffset]);.Ve.SpIf truncation occurs, \f(CW$ora_errno\fR will be set to 1406. &\fIora_fetch()\fRwill complete successfully if truncation is permitted, otherwise itwill fail..Sp&\fIora_fetch()\fR will fail at the end of the data or if an error occurs. Itis possible to distinguish between these cases by testing the value ofthe variable \f(CW$ora_errno\fR. This will be zero for end of data, non-zero ifan error has occurred..SpExample:.Sp.Vb 6\& while (($deptno, $dname, $loc) = &ora_fetch($csr))\& {\& warn "Truncated!!!" if $ora_errno == 1406;\& # do something with the data\& }\& warn $ora_errstr if $ora_errno;.Ve.SpThis function is equivalent to the \s-1OCI\s0 ofetch function..IP "\(bu" 2ora_close.Sp.Vb 1\& &ora_close($csr).Ve.SpIf an \s-1SQL\s0 statement is no longer required (for example, all the dataselected has been processed, or no more rows are to be inserted) thenthe statement identifier should be released. This is done by callingthe &\fIora_close()\fR function with the statement identifier as its onlyparameter..SpThis function is equivalent to the \s-1OCI\s0 oclose function..Sp\&\fB\s-1DBD:\s0\fR Since \f(CW$csr\fR is a Perl5 reference the statement/cursor is nowautomatically closed if \f(CW$csr\fR is overwritten or goes out of scope..IP "\(bu" 2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -