怎么得到记录集的例子
conn = OCILogon("user","pw","server.world"); $sql=" 
declare 
type c_type is ref cursor; 
c_data c_type; 
c_null tab.row_id%type; 
begin 
open :c_data for 
select row_id from tab order by row_id; 
while :c_data%rowcount < :c_init loop 
fetch :c_data into c_null; 
end loop; 
end; 
"; $stmt=OCIParse($conn, $sql); 
$curs=OCINewCursor($conn); $offset=100; // dont fetch the first 100 rows 
$limit=10; // we want exactly 10 rows OCIBindByName($stmt,":c_init",$offset,32); 
OCIBindByName($stmt,":c_data",$curs,-1,OCI_B_CURSOR); OCIExecute($stmt); 
OCIExecute($curs); for ($i=0;$i<$limit&&OCIFetchinto($curs,$cols,OCI_ASSOC);$i++) 
print $cols[ROW_ID]."\n"; OCIFreeStatement($stmt); 
OCIFreeCursor($curs); 
OCILogoff($conn); 

解决方案 »

  1.   

    我试了你的代码,可是还是不行呀,有错误!Warning: OCIStmtExecute: ORA-06550: 行1、列5: PLS-00103: 出现符号""在需要下列之一时: begindeclareexitforfunctiongoto ifloopmodnullpackagepragmaprocedureraisereturnselectseparate typeupdatewhilewith << formtableclosecurrentdefinedeletefetchlockinsertopenrollback savepointsetsqlcommitlibrary in c:\estar\test2.php on line 27Warning: OCIFetchInto: OCI_INVALID_HANDLE in c:\estar\test2.php on line 30<?php
    $conn  =  OCILogon(  "system",  "manager",  "grief.world");    
     
    $sql=  "    
    declare    
    type  c_type  is  ref  cursor;    
    c_data  c_type;    
    c_null  tab.row_id%type;    
    begin    
    open  :c_data  for    
    select  row_id  from  tab  order  by  row_id;    
    while  :c_data%rowcount    <  :c_init  loop    
    fetch  :c_data  into  c_null;    
    end  loop;    
    end;    
     ";    
     
    $stmt=OCIParse($conn,  $sql);    
    $curs=OCINewCursor($conn);    
     
    $offset=100;  //  dont  fetch  the  first  100  rows    
    $limit=10;  //  we  want  exactly  10  rows    
     
    OCIBindByName($stmt,  ":c_init",$offset,32);    
    OCIBindByName($stmt,  ":c_data",$curs,-1,OCI_B_CURSOR);    
     
    OCIExecute($stmt);
    OCIExecute($curs);    
     
    for($i=0;$i<$limit&&OCIFetchinto($curs,$cols,OCI_ASSOC);$i++)    
    print $cols[ROW_ID]."\n";    
     
    OCIFreeStatement($stmt);    
    OCIFreeCursor($curs);    
    OCILogoff($conn);   
    ?>我自已写的是这样
    //存储过程
    CREATE OR REPLACE PACKAGE MyType
    AS
        type c_type is ref cursor;
    END MyType;
    CREATE OR REPLACE PROCEDURE TEST
    (
         ParaIn varchar2,
         CursorOut OUT MyType.c_type
    ) ISBegin
        Open CursorOut For
          Select * from wstate2;
    End TEST; 
    //PHP
    <?
    $conn=OCILogon("estar","star","estar");$sql="
    declare    
    type c_type is ref cursor;    
    CursorOut c_type;  
    Begin 
        Test('luo',:CursorOut);
    End;";$stmt=OCIParse($conn,$sql);OCIBindByName($stmt,":CursorOut",$cursor,-1,OCI_B_CURSOR);   
    OCIExecute($stmt);for($i=0;$i<$limit&&OCIFetchinto($cursor,$cols,OCI_ASSOC);$i++)
    print $cols[ID]."\n";OCIFreeStatement($stmt);
    OCILogoff($conn);
    ?>//错误
    Warning: Supplied argument is not a valid OCI8-Statement resource in c:\estar\test.php on line 14Warning: OCIStmtExecute: ORA-06550: 行1、列1: PLS-00103: 出现符号""在需要下列之一时: begindeclareexitforfunctiongoto ifloopmodnullpackagepragmaprocedureraisereturnselectseparate typeupdatewhilewith << formtableclosecurrentdefinedeletefetchlockinsertopenrollback savepointsetsqlcommitlibrary in c:\estar\test.php on line 15
      

  2.   

    ORA-06550错误是因为不能识别变量的原因,把CIOTABLE_DEFINITION 设置一下应该有帮助(我学oracle也不太久)
    第一个问题Warning: Supplied argument is not a valid OCI8-Statement resource in c:\estar\test.php on line 14我用的是Linux 6.4 +Oracle 8.1.6 R2 +apache1.3.12+php4.0.2)
    (./configure --with-oci8=/u/u01/app/oracle/product/8.1.6 )没有出现这个问题啊,你怎么配置的?
      

  3.   

    oracle我也刚用
    不太清楚你说的什么