⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbd::oraperl.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 2 页
字号:
ora_do.Sp.Vb 1\&  &ora_do($lda, $statement).Ve.SpNot all \s-1SQL\s0 statements return data or contain substitutionvariables. In these cases the &\fIora_do()\fR function may beused as an alternative to &\fIora_open()\fR and &\fIora_close()\fR.This function takes two parameters, a login identifier andthe statement to be executed..SpExample:.Sp.Vb 1\& &ora_do($lda, \*(Aqdrop table employee\*(Aq);.Ve.SpThis function is roughly equivalent to.Sp.Vb 1\& &ora_close( &ora_open($lda, $statement) ).Ve.Sp\&\fB\s-1DBD:\s0\fR oraperl v2 used to return the string '\s-1OK\s0' to indicatesuccess with a zero numeric value. The Oraperl emulation nowuses the string '0E0' to achieve the same effect since it doesnot cause any \f(CW\*(C`\-w\*(C'\fR warnings when used in a numeric context..IP "\(bu" 2ora_logoff.Sp.Vb 1\&  &ora_logoff($lda).Ve.SpWhen the program no longer needs to access a given database, the loginidentifier should be released using the &\fIora_logoff()\fR function..SpThis function is equivalent to the \s-1OCI\s0 ologoff function..Sp\&\fB\s-1DBD:\s0\fR Since \f(CW$lda\fR is a Perl5 reference the database login identifieris now automatically released if \f(CW$lda\fR is overwritten or goes out of scope..Sh "Ancillary Functions".IX Subsection "Ancillary Functions"Additional functions available are: &\fIora_titles()\fR,&\fIora_lengths()\fR, &\fIora_types()\fR, &\fIora_autocommit()\fR,&\fIora_commit()\fR, &\fIora_rollback()\fR and &\fIora_version()\fR..PPThe first three are of most use within a program whichallows statements to be entered interactively. See, forexample, the sample program sql which is supplied withOraperl and may have been installed at your site..IP "\(bu" 2ora_titles.Sp.Vb 1\&  @titles = &ora_titles($csr).Ve.SpA program may determine the field titles of an executedquery by calling &\fIora_titles()\fR. This function takes asingle parameter, a statement identifier (obtained from&\fIora_open()\fR) indicating the query for which the titles arerequired. The titles are returned as an array of strings,one for each column..SpTitles are truncated to the length of the field, as reportedby the &\fIora_lengths()\fR function..Sp\&\fB\s-1DBD:\s0\fR oraperl v2.2 actually changed the behaviour such that thetitles were not truncated unless an optional second parameter wastrue.  This was not reflected in the oraperl manual.  The Oraperlemulation adopts the non truncating behaviour and doesn't support thetruncate parameter..IP "\(bu" 2ora_lengths.Sp.Vb 1\&  @lengths = &ora_lengths($csr).Ve.SpA program may determine the length of each of the fieldsreturned by a query by calling the &\fIora_lengths()\fR function.This function takes a single parameter, a statementidentifier (obtained from &\fIora_open()\fR) indicating the queryfor which the lengths are required. The lengths arereturned as an array of integers, one for each column..IP "\(bu" 2ora_types.Sp.Vb 1\&  @types = &ora_types($csr).Ve.SpA program may determine the type of each of the fields returned by aquery by calling the &\fIora_types()\fR function.  This function takes asingle parameter, a statement identifier (obtained from &\fIora_open()\fR)indicating the query for which the lengths are required. The types arereturned as an array of integers, one for each field..SpThese types are defined in your \s-1OCI\s0 documentation. The correctinterpretation for Oracle v6 is given in the file oraperl.ph..IP "\(bu" 2ora_autocommit.Sp.Vb 1\&  &ora_autocommit($lda, $on_or_off).Ve.SpAutocommit mode (in which each transaction is committed immediately,without waiting for an explicit commit) may be enabled or disabledusing &\fIora_autocommit()\fR. This function takes two parameters, a loginidentifier (obtained from &\fIora_login()\fR) and a true/false valueindicating whether autocommit is to be enabled (non-zero) or disabled(zero).  By default, autocommit is off..SpNote that autocommit can only be set per login, not per statement. Ifyou need to control autocommit by statement (for example, to allowdeletions to be rolled back, but insertions to be committedimmediately) you should make multiple calls to &\fIora_login()\fR and use aseparate login identifier for each statement..IP "\(bu" 2ora_commit, ora_rollback.Sp.Vb 2\&  &ora_commit($lda)\&  &ora_rollback($lda).Ve.SpModifications to a database may be committed or rolled back using the&\fIora_commit()\fR and &\fIora_rollback()\fR functions.  These functions take asingle parameter, a login identifier obtained from &\fIora_login()\fR..SpTransactions which have been committed (either explicitly by a call to&\fIora_commit()\fR or implicitly through the use of &\fIora_autocommit()\fR)cannot be subsequently rolled back..SpNote that commit and rollback can only be used per login, not perstatement. If you need to commit or rollback by statement you shouldmake multiple calls to &\fIora_login()\fR and use a separate login identifierfor each statement..IP "\(bu" 2ora_version.Sp.Vb 1\&  &ora_version().Ve.SpThe &\fIora_version()\fR function prints the version number andcopyright information concerning Oraperl. It also printsthe values of various compilation time options. It does notreturn any value, and should not normally be used in aprogram..SpExample:.Sp.Vb 1\&  perl \-MOraperl \-e \*(Aqora_version()\*(Aq\&\&  This is Oraperl, version 2, patch level 0.\&\&  Debugging is available, including the \-D flag.\&  Default fetch row cache size is 5.\&  Empty bind values are replaced by a space.\&\&  Perl is copyright by Larry Wall; type oraperl \-v for details.\&  Additions for oraperl: Copyright 1991, 1992, Kevin Stock.\&\&  Oraperl may be distributed under the same conditions as Perl..Ve.SpThis function is the equivalent of Perl's \f(CW\*(C`\-v\*(C'\fR flag..Sp\&\fB\s-1DBD:\s0\fR The Oraperl emulation printout is similar but not identical..SH "VARIABLES".IX Header "VARIABLES"Six special variables are provided, \f(CW$ora_cache\fR, \f(CW$ora_long\fR,\&\f(CW$ora_trunc\fR, \f(CW$ora_errno\fR, \f(CW$ora_errstr\fR and \f(CW$ora_verno\fR..Sh "Customisation Variables".IX Subsection "Customisation Variables"These variables are used to dictate the behaviour of Oraperlunder certain conditions..IP "\(bu" 2\&\f(CW$ora_cache\fR.SpThe \f(CW$ora_cache\fR variable determines the default cache size used by the&\fIora_open()\fR function for \s-1SELECT\s0 statements if an explicit cache size isnot given..SpIt is initialised to the default value reported by &\fIora_version()\fR butmay be set within a program to apply to all subsequent calls to&\fIora_open()\fR. Cursors which are already open are not affected. Asdistributed, the default value is five, but may have been altered atyour installation..SpAs a special case, assigning zero to \f(CW$ora_cache\fR resets it to thedefault value. Attempting to set \f(CW$ora_cache\fR to a negative value resultsin a warning..IP "\(bu" 2\&\f(CW$ora_long\fR.SpNormally, Oraperl interrogates the database to determine the length ofeach field and allocates buffer space accordingly.  This is notpossible for fields of type \s-1LONG\s0 or \s-1LONGRAW\s0. To allocate spaceaccording to the maximum possible length (65535 bytes) would obviouslybe extremely wasteful of memory..SpTherefore, when &\fIora_open()\fR determines that a field is a \s-1LONG\s0 type, itallocates the amount of space indicated by the \f(CW$ora_long\fR variable. Thisis initially set to 80 (for compatibility with Oracle products) but maybe set within a program to whatever size is required..Sp\&\f(CW$ora_long\fR is only used when fetching data, not when inserting it..IP "\(bu" 2\&\f(CW$ora_trunc\fR.SpSince Oraperl cannot determine exactly the maximum length of a \s-1LONG\s0field, it is possible that the length indicated by \f(CW$ora_long\fR is notsufficient to store the data fetched. In such a case, the optionalsecond parameter to &\fIora_fetch()\fR indicates whether the truncationshould be allowed or should provoke an error..SpIf this second parameter is not specified, the value of \f(CW$ora_trunc\fR isused as a default. This only applies to \s-1LONG\s0 and \s-1LONGRAW\s0 data types.Truncation of a field of any other type is always considered an error(principally because it indicates a bug in Oraperl)..Sh "Status Variables".IX Subsection "Status Variables"These variables report information about error conditions or aboutOraperl itself. They may only be read; a fatal error occurs if aprogram attempts to change them..IP "\(bu" 2\&\f(CW$ora_errno\fR.Sp\&\f(CW$ora_errno\fR contains the Oracle error code provoked by the last functioncall..SpThere are two cases of particular interest concerning &\fIora_fetch()\fR. Ifa \s-1LONG\s0 or \s-1LONGRAW\s0 field is truncated (and truncation is allowed) then&\fIora_fetch()\fR will complete successfully but \f(CW$ora_errno\fR will be set to1406 to indicate the truncation. When &\fIora_fetch()\fR fails, \f(CW$ora_errno\fRwill be set to zero if this was due to the end of data or an error codeif it was due to an actual error..IP "\(bu" 2\&\f(CW$ora_errstr\fR.SpThe \f(CW$ora_errstr\fR variable contains the Oracle error messagecorresponding to the current value of \f(CW$ora_errno\fR..IP "\(bu" 2\&\f(CW$ora_verno\fR.SpThe \f(CW$ora_verno\fR variable contains the version number of Oraperl in theform v.ppp where v is the major version number and ppp is thepatchlevel. For example, in Oraperl version 3, patch level 142,\&\f(CW$ora_verno\fR would contain the value 3.142 (more or less, allowing forfloating point error)..SH "SUBSTITUTION VARIABLES".IX Header "SUBSTITUTION VARIABLES"Oraperl allows an \s-1SQL\s0 statement to contain substitution variables.These consist of a colon followed by a number.  For example, a programwhich added records to a telephone list might use the following call to&\fIora_open()\fR:.PP.Vb 1\&  $csr = &ora_open($csr, "insert into telno values(:1, :2)");.Ve.PPThe two names :1 and :2 are called substitution variables.  Thefunction &\fIora_bind()\fR is used to assign values to these variables. Forexample, the following statements would add two new people to thelist:.PP.Vb 2\&  &ora_bind($csr, "Annette", "472\-8836");\&  &ora_bind($csr, "Brian", "937\-1823");.Ve.PPNote that the substitution variables must be assigned consecutivelybeginning from 1 for each \s-1SQL\s0 statement, as &\fIora_bind()\fR assigns itsparameters in this order. Named substitution variables (for example,:NAME, :TELNO) are not permitted..PP\&\fB\s-1DBD:\s0\fR Substitution variables are now bound as type 1 (\s-1VARCHAR2\s0)and not type 5 (\s-1STRING\s0) by default. This can alter the behaviour of\&\s-1SQL\s0 code which compares a char field with a substitution variable.See the String Comparison section in the Datatypes chapter of theOracle \s-1OCI\s0 manual for more details..PPYou can work around this by using DBD::Oracle's ability to specifythe Oracle type to be used on a per field basis:.PP.Vb 5\&  $char_attrib = { ora_type => 5 }; # 5 = STRING (ala oraperl2.4)\&  $csr = ora_open($dbh, "select foo from bar where x=:1 and y=:2");\&  $csr\->bind_param(1, $value_x, $char_attrib);\&  $csr\->bind_param(2, $value_y, $char_attrib);\&  ora_bind($csr);  # bind with no parameters since we\*(Aqve done bind_param()\*(Aqs.Ve.SH "DEBUGGING".IX Header "DEBUGGING"\&\fB\s-1DBD:\s0\fR The Oraperl \f(CW$ora_debug\fR variable is not supported. Howeverdetailed debugging can be enabled at any time by executing.PP.Vb 1\&  $h\->debug(2);.Ve.PPwhere \f(CW$h\fR is either a \f(CW$lda\fR or a \f(CW$csr\fR. If debugging is enabled on an\&\f(CW$lda\fR then it is automatically passed on to any cursors returned by&\fIora_open()\fR..SH "EXAMPLE".IX Header "EXAMPLE".Vb 4\&  format STDOUT_TOP =\&  Name Phone\&  ==== =====\&  .\&\&  format STDOUT =\&  @<<<<<<<<<< @>>>>>>>>>>\&  $name, $phone\&  .\&\&  die "You should use oraperl, not perl\en" unless defined &ora_login;\&  $ora_debug = shift if $ARGV[0] =~ /^\e\-#/;\&\&  $lda = &ora_login(\*(Aqt\*(Aq, \*(Aqkstock\*(Aq, \*(Aqkstock\*(Aq)\&            || die $ora_errstr;\&  $csr = &ora_open($lda, \*(Aqselect * from telno order by name\*(Aq)\&            || die $ora_errstr;\&\&  $nfields = &ora_fetch($csr);\&  print "Query will return $nfields fields\en\en";\&\&  while (($name, $phone) = &ora_fetch($csr)) { write; }\&  warn $ora_errstr if $ora_errno;\&\&  die "fetch error: $ora_errstr" if $ora_errno;\&\&  do ora_close($csr) || die "can\*(Aqt close cursor";\&  do ora_logoff($lda) || die "can\*(Aqt log off Oracle";.Ve.SH "NOTES".IX Header "NOTES"In keeping with the philosophy of Perl, there is no pre-defined limitto the number of simultaneous logins or \s-1SQL\s0 statements which may beactive, nor to the number of data fields which may be returned by aquery. The only limits are those imposed by the amount of memoryavailable, or by Oracle..SH "WARNINGS".IX Header "WARNINGS"The Oraperl emulation software shares no code with the originaloraperl. It is built on top of the new Perl5 \s-1DBI\s0 and DBD::Oraclemodules.  These modules are still evolving. (One of the goals ofthe Oraperl emulation software is to allow useful work to be donewith the \s-1DBI\s0 and DBD::Oracle modules whilst insulating users fromthe ongoing changes in their interfaces.).PPIt is quite possible, indeed probable, that some differences inbehaviour will exist. These are probably confined to error handling..PP\&\fBAll\fR differences in behaviour which are not documented here should bereported to to dbi\-users@perl.org..SH "SEE ALSO".IX Header "SEE ALSO".IP "Oracle Documentation" 2.IX Item "Oracle Documentation"\&\s-1SQL\s0 Language Reference Manual.Programmer's Guide to the Oracle Call Interfaces..IP "Books" 2.IX Item "Books"Programming Perl by Larry Wall and Randal Schwartz.Learning Perl by Randal Schwartz..IP "Manual Pages" 2.IX Item "Manual Pages"\&\fIperl\fR\|(1).SH "AUTHOR".IX Header "AUTHOR"Original Oraperl 2.4 code and documentationby Kevin Stock <kstock@auspex.fr>..PP\&\s-1DBI\s0 and Oraperl emulation using DBD::Oracle by Tim Bunce..SH "MAINTAINER".IX Header "MAINTAINER"As of DBD::Oracle release 1.17 in February 2006 The Pythian Group, Inc.(<http://www.pythian.com>) are taking the lead in maintaining DBD::Oracle withmy assistance and gratitude..SH "COPYRIGHT".IX Header "COPYRIGHT"Copyright (c) 1994\-2006 Tim Bunce. Ireland..PPThe DBD::Oracle module is free open source software; you canredistribute it and/or modify it under the same terms as Perl 5.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -