Home Database Mysql Tutorial Oracle 8 资料库函式库

Oracle 8 资料库函式库

Jun 07, 2016 pm 03:14 PM
oracle Community database Enter

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入 由于本函式库都是呼叫 Oracle8 Call-Interface (OCI8) 来存取 Oracle 资料库,因此在装设 Oracle 8 Client 的 Web 伺服器上,可用本函式库存取 Oracle 7.x 或 8.x 二种版本的资料库伺服器。 OCIDefi

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入

    由于本函式库都是呼叫 Oracle8 Call-Interface (OCI8) 来存取 Oracle 资料库,因此在装设 Oracle 8 Client 的 Web 伺服器上,可用本函式库存取 Oracle 7.x 或 8.x 二种版本的资料库伺服器。


OCIDefineByName: 让 SELECT 指令可使用 PHP 变数。
OCIBindByName: 让动态 SQL 可使用 PHP 变数。
OCILogon: 开启与 Oracle 的连结。
OCILogOff: 关闭与 Oracle 的连结。
OCIExecute: 执行 Oracle 的指令区段。
OCICommit: 将 Oracle 的交易处理付诸实行。
OCIRollback: 撤消当前交易。
OCINumRows: 取得受影响栏位的数目。
OCIResult: 从目前列 (row) 的资料取得一栏 (column)。
OCIFetch: 取得传回资料的一列 (row)。
OCIFetchInto: 取回 Oracle 资料放入阵列。
OCIColumnIsNULL: 测试传回行是否为空的。
OCIColumnSize: 取得栏位型态的大小。
OCINewDescriptor: 初始新的 LOB/FILE 描述。
OCIParse: 分析 SQL 语法。

    要使用这个函式库,要在安装 PHP 及 Apache Server 之前先将 Oracle 资料库安装好,并确定 Oracle 能够顺利运作。之后在 PHP 设定 (configure) 时加入 --with-oracle=DIR 的选项,DIR 就是 $ORACLE_HOME 环境变数,例如:

<font face="新宋体">./configure --with-oracle=/abc/def/oracle/product/7.0.3 --with-apache=../apache_1.3.x --enable-track-vars</font>

    以下的范例是 stevel@nettek-llc.com (22-Jan-1999) 所提供的。这个范例是传回 Oracle 中 sid1 资料库 (Database) 的 EMP 资料表 (Table) 所有资料。帐号是 SCOTT、密码为 TIGER。


putenv
("ORACLE_SID=sid1");
putenv("ORACLE_HOME=/u01/app/oracle/product/8.0.5");

$handle ora_plogon("SCOTT@sid1",  "TIGER") or die;
$cursor ora_open($handle);
ora_commitoff($handle);

$query "SELECT * FROM EMP";
ora_parse($cursor$query) or die;
ora_exec($cursor);

echo  
"

\n"<font>;<br>echo  </font><font>"$query</font><font>\n\n</font><font>"</font><font>;<br></font><font>$numcols </font><font>= </font><font>0</font><font>;<br>while(</font><font>ora_fetch</font><font>(</font><font>$cursor</font><font>)) {<br>    </font><font>$numcols </font><font>= </font><font>ora_numcols</font><font>(</font><font>$cursor</font><font>);<br>    for (</font><font>$column</font><font>=</font><font>0</font><font>; </font><font>$column </font><font><font>$numcols</font><font>; </font><font>$column</font><font>++) {<br>        </font><font>$data </font><font>= </font><font>trim</font><font>(</font><font>ora_getcolumn</font><font>(</font><font>$cursor</font><font>, </font><font>$column</font><font>));<br>        if(</font><font>$data </font><font>==  </font><font>""</font><font>) </font><font>$data </font><font>= </font><font>"NULL"</font><font>;<br>        echo  </font><font>"$data</font><font>\t</font><font>"</font><font>;<br>    }<br>    echo  </font><font>"\n"</font><font>;<br>}<br></font><font>$numrows </font><font>= </font><font>ora_numrows</font><font>(</font><font>$cursor</font><font>);<br>echo  </font><font>"</font><font>\n</font><font>ROWS RETURNED: $numrows</font><font>\n</font><font>"</font><font>;<br>echo  </font><font>"</font></font>
Copy after login
\n";

ora_close($cursor);

?>

kk@shonline.de (05-Aug-1998) 指出 ORACLE_HOME 为 Oracle 的安装路径,ORACLE_SID 为 Oracle 的资料库名称,若不知道这二个环境变数可以用 sqlplus 连上 Oracle 来查证。

Ora_Bind: 连结 PHP 变数到 Oracle 参数。
Ora_Close: 关闭一个 Oracle 的 cursor。
Ora_ColumnName: 得到 Oracle 传回列 (Column) 的名称。
Ora_ColumnType: 得到 Oracle 传回列 (Column) 的型态。
Ora_Commit: 将 Oracle 的交易处理付诸实行。
Ora_CommitOff: 关闭自动执行 Oracle 交易更动的功能。
Ora_CommitOn: 打开自动执行 Oracle 交易更动的功能。
Ora_Error: 获得 Oracle 错误讯息。
Ora_ErrorCode: 获得 Oracle 错误代码。
Ora_Exec: 执行 Oracle 的指令区段。
Ora_Fetch: 取得传回资料的一列 (row)。
Ora_GetColumn: 从传回列 (row) 的资料取得一栏 (column)。
Ora_Logoff: 结束与 Oracle 的连结。
Ora_Logon: 开启与 Oracle 的连结。
Ora_Open: 开启 Oracle 的 cursor。
Ora_Parse: 分析 SQL 语法。
Ora_Rollback: 撤消当前交易。
Ora_Do: 快速的 SQL 查询。
Ora_FetchInto: 取回 Oracle 资料放入阵列。
Ora_ColumnSize: 取得栏位型态的大小。
Ora_Numcols: 取得栏位的数目。
Ora_PLogon: 开启与 Oracle 的长期连结。

 

Oracle 8 资料库函式库

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to encrypt oracle view How to encrypt oracle view Apr 11, 2025 pm 08:30 PM

Oracle View Encryption allows you to encrypt data in the view, thereby enhancing the security of sensitive information. The steps include: 1) creating the master encryption key (MEk); 2) creating an encrypted view, specifying the view and MEk to be encrypted; 3) authorizing users to access the encrypted view. How encrypted views work: When a user querys for an encrypted view, Oracle uses MEk to decrypt data, ensuring that only authorized users can access readable data.

How to uninstall Oracle installation failed How to uninstall Oracle installation failed Apr 11, 2025 pm 08:24 PM

Uninstall method for Oracle installation failure: Close Oracle service, delete Oracle program files and registry keys, uninstall Oracle environment variables, and restart the computer. If the uninstall fails, you can uninstall manually using the Oracle Universal Uninstall Tool.

How to solve the problem of closing oracle cursor How to solve the problem of closing oracle cursor Apr 11, 2025 pm 10:18 PM

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

How to check invalid numbers of oracle How to check invalid numbers of oracle Apr 11, 2025 pm 08:27 PM

Oracle Invalid numeric errors may be caused by data type mismatch, numeric overflow, data conversion errors, or data corruption. Troubleshooting steps include checking data types, detecting digital overflows, checking data conversions, checking data corruption, and exploring other possible solutions such as configuring the NLS_NUMERIC_CHARACTERS parameter and enabling data verification logging.

How to create cursors in oracle loop How to create cursors in oracle loop Apr 12, 2025 am 06:18 AM

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

How to set up users of oracle How to set up users of oracle Apr 11, 2025 pm 08:21 PM

To create a user in Oracle, follow these steps: Create a new user using the CREATE USER statement. Grant the necessary permissions using the GRANT statement. Optional: Use the RESOURCE statement to set the quota. Configure other options such as default roles and temporary tablespaces.

How to delete all data from oracle How to delete all data from oracle Apr 11, 2025 pm 08:36 PM

Deleting all data in Oracle requires the following steps: 1. Establish a connection; 2. Disable foreign key constraints; 3. Delete table data; 4. Submit transactions; 5. Enable foreign key constraints (optional). Be sure to back up the database before execution to prevent data loss.

How to create oracle dynamic sql How to create oracle dynamic sql Apr 12, 2025 am 06:06 AM

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values ​​to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.

See all articles