« oci_new_connect
oci_new_descriptor »

oci_new_cursor

(PHP 5, PHP 7, PHP 8, PECL OCI8 >= 1.1.0)

oci_new_cursor — 新規カーソル (ステートメントハンドル) を割り当て、それを返す

説明

function oci_new_cursor(resource $connection): resource|false

指定された接続に新規カーソルを割り当てます。

パラメータ

connection

oci_connect() あるいは oci_pconnect() が返す Oracle 接続 ID。

戻り値

新しいステートメントハンドル、あるいはエラー時に false を返します。

例

例1 Oracle ストアドプロシージャにおける REF CURSOR のバインド

<?php

// 以下のプロシージャを用意します
//   create or replace procedure myproc(myrc out sys_refcursor) as
//   begin
//     open myrc for select first_name from employees;
//   end;

$conn = oci_connect("hr", "hrpwd", "localhost/XE");
if (!$conn) {
    $m = oci_error();
    trigger_error(htmlentities($m['message']), E_USER_ERROR);
}

$curs = oci_new_cursor($conn);
$stid = oci_parse($conn, "begin myproc(:cursbv); end;");
oci_bind_by_name($stid, ":cursbv", $curs, -1, OCI_B_CURSOR);
oci_execute($stid);

oci_execute($curs);  // REF CURSOR を、ステートメント ID のように利用します
while (($row = oci_fetch_array($curs, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
    echo $row['FIRST_NAME'] . "<br />\n";
}

oci_free_statement($stid);
oci_free_statement($curs);
oci_close($conn);

?>

関連キーワード:
ステートメント   conn   curs   カーソル   ハンドル   cursor   stid   connect   resource   connection   接続   Oracle   プロシージャ   myproc   myrc   begin   cursbv   execute   free   statement   descriptor   pconnect   ストアド   バインド   用意
関連する関数・ページ:
function.oci-parse   function.db2-cursor-type   function.oci-error   function.oci-statement-type   function.oci-field-type-raw   function.oci-bind-by-name