首页 \ 问答 \ 从PHP调用Oracle存储过程(Call Oracle stored procedure from PHP)

从PHP调用Oracle存储过程(Call Oracle stored procedure from PHP)

我正在尝试执行并从我的过程中获取数据:

这是我的程序定义的方式:

create or replace PROCEDURE SP_GET_MY_DATA(
         IN_POP VARCHAR2,
         IN_SEG VARCHAR2,
         IN_DUR VARCHAR2, 
         IN_VIEW INTEGER, 
         IN_PAGE INTEGER, 
         VIEW_DATA_CUR OUT SYS_REFCURSOR) AS ...

这里是我的PHP代码来执行并从程序中获取数据:

$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = JXYX.com)(PORT = 1521)))(CONNECT_DATA=(SID=DHSJKS)))";
$conn = ocilogon("XXXXXX","XXXXXXXX",$db);          

$sql = 'BEGIN SP_GET_MY_DATA(:POP, :SEG, :DUR, :VIEW, :PAGE, :OUTPUT_CUR); END;';            

$stmt = oci_parse($conn,$sql);                     
oci_bind_by_name($stmt,':POP',$pop);           
oci_bind_by_name($stmt,':SEG',$seg);           
oci_bind_by_name($stmt,':DUR',$dur);           
oci_bind_by_name($stmt,':VIEW',$view);           
oci_bind_by_name($stmt,':PAGE',$page);           
$OUTPUT_CUR = oci_new_cursor($conn);
oci_bind_by_name($stmt,":OUTPUT_CUR", $OUTPUT_CUR, -1, OCI_B_CURSOR);                   
oci_execute($stmt, OCI_DEFAULT); 

while ($data = oci_fetch_assoc($OUTPUT_CUR)) {
    print_r($data);
}

但是这样做我收到了这个错误:

oci_fetch_assoc():ORA-24374:在获取或执行并获取之前定义未完成。

我无法弄清楚我错过了什么。 你能帮我吗?


I am trying to execute and get data from my procedure:

Here is the way my procedure is defined:

create or replace PROCEDURE SP_GET_MY_DATA(
         IN_POP VARCHAR2,
         IN_SEG VARCHAR2,
         IN_DUR VARCHAR2, 
         IN_VIEW INTEGER, 
         IN_PAGE INTEGER, 
         VIEW_DATA_CUR OUT SYS_REFCURSOR) AS ...

Here is my PHP code to execute and get data from procedure:

$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = JXYX.com)(PORT = 1521)))(CONNECT_DATA=(SID=DHSJKS)))";
$conn = ocilogon("XXXXXX","XXXXXXXX",$db);          

$sql = 'BEGIN SP_GET_MY_DATA(:POP, :SEG, :DUR, :VIEW, :PAGE, :OUTPUT_CUR); END;';            

$stmt = oci_parse($conn,$sql);                     
oci_bind_by_name($stmt,':POP',$pop);           
oci_bind_by_name($stmt,':SEG',$seg);           
oci_bind_by_name($stmt,':DUR',$dur);           
oci_bind_by_name($stmt,':VIEW',$view);           
oci_bind_by_name($stmt,':PAGE',$page);           
$OUTPUT_CUR = oci_new_cursor($conn);
oci_bind_by_name($stmt,":OUTPUT_CUR", $OUTPUT_CUR, -1, OCI_B_CURSOR);                   
oci_execute($stmt, OCI_DEFAULT); 

while ($data = oci_fetch_assoc($OUTPUT_CUR)) {
    print_r($data);
}

But in doing so I am getting this error:

oci_fetch_assoc(): ORA-24374: define not done before fetch or execute and fetch".

I am not able to figure out what I'm missing. Can you help?


原文:https://stackoverflow.com/questions/41506335
更新时间:2022-01-05 06:01

最满意答案

我看到的一个问题是: parentsSeq +: Seq(parent) 。 这不会改变序列,它会返回一个新的序列。


One problem I see is here: parentsSeq +: Seq(parent). This doesn't mutate the sequence, it returns a new sequence instead.

相关问答

更多
  • 您根本不需要特殊的f函数,只需生成executor.submit返回的Future: from concurrent.futures import ThreadPoolExecutor executor = ThreadPoolExecutor(10) @gen.coroutine def my_coroutine(...) ... future = executor.submit(func, *args, **kwargs) result = yield future You ...
  • .then()的参数类型错误。 尝试: .then((_) => play2(pickRandomSoundFrequency())) 您需要传递一个要调用的函数,而不是在构造参数时调用该函数。 You have the wrong type for the argument of .then(). Try: .then((_) => play2(pickRandomSoundFrequency())) You need to pass a function to be called, not call ...
  • 你所追求的是像这样的allMatch()方法: boolean result = futures.stream().allMatch(booleanFuture -> { try { return booleanFuture.get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } }); 如果 ...
  • 在我的高并发应用程序中使用ThreadPoolExecutor与gevent ,我可以确认这是正常的。 但是,如果数据库驱动程序已经gevent “友好”那样不必要了: psycogreen After using ThreadPoolExecutor with gevent in my high-concurrent app I can confirm that this works fine. But unnecessary if the DB Driver is already gevent "fri ...
  • 我看到的一个问题是: parentsSeq +: Seq(parent) 。 这不会改变序列,它会返回一个新的序列。 One problem I see is here: parentsSeq +: Seq(parent). This doesn't mutate the sequence, it returns a new sequence instead.
  • 我如何在dart中执行此jquery模式的代码? 看起来和你的很相似 对于_db.keys()的每个条目, _db.keys()一个未来添加到数组中,然后等待所有这些都由Future.wait()完成 不确定此代码是否有效(请参阅关于链接问题的答案的评论) void fnA() { fnB().then((_) { // Here, all keys should have been loaded }); } Future fnB() { return _db.open ...
  • 这一切都取决于执行者 。 假设您使用Executors.newFixedThreadPool(n)创建了一个Executor并向其提交了n * 100个任务,那么运行的线程不会超过n个 。 如果您正在使用Clojure的未来功能,它会将您的任务提交给clojure.lang.Agent.soloExecutor 。 soloExecutor是使用Executors.newCachedThreadPool(threadFactory)创建的,因此它将重用线程并尽可能多地运行。 It all depends o ...
  • 看起来你可以简单地维护一个Map, Callable>而不是List>并以这种方式检索原始的Callable。 如果你想变得非常聪明,你可以做OO风格并扩展ThreadPoolExecutor并创建一个Future装饰器类。 我认为这可能是矫枉过正,但你可以这样做: import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException ...
  • 创建涉及异步计算的Flow的最简单方法是使用mapAsync 。 所以......假设你想要创建一个使用异步计算mapper: Int => Future[String]消耗Int并生成String的Flow mapper: Int => Future[String] ,并行度为5。 val mapper: Int => Future[String] = (i: Int) => Future(i.toString) val yourFlow = Flow[Int].mapAsync[String](5)( ...
  • 你的代码中有一个拼写错误。 Posts.allow({ update: ownsDocument, remote: ownsDocument }); 应改为 Posts.allow({ update: ownsDocument, remove: ownsDocument }); there is a typo in your code. Posts.allow({ update: ownsDocument, remote: ownsDocument }); ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。