dan*_*ang 6 php oracle stored-procedures
我有一个存储过程,我从PHP运行使用:
//Request does not change
$sql = 'BEGIN SP_GET_MY_DATA(:POP, :SEG, :DUR, :VIEW, :PAGE, :OUTPUT_CUR); END;';            
//Statement does not change
$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);    
//But BEFORE statement, Create your cursor
$cursor = oci_new_cursor($conn)
// On your code add the latest parameter to bind the cursor resource to the Oracle argument
oci_bind_by_name($stmt,":OUTPUT_CUR", $cursor,-1,OCI_B_CURSOR);
// Execute the statement as in your first try
oci_execute($stmt);
// and now, execute the cursor
oci_execute($cursor);
// Use OCIFetchinto in the same way as you would with SELECT
while ($data = oci_fetch_assoc($cursor, OCI_RETURN_LOBS )) {
    print_r($data}
}
问题是我在存储过程中有数百万行和复杂的逻辑.当我通过SQL开发人员执行SP_GET_MY_DATA时,完成它大约需要2个小时.
当我这样做时,PHP会超时.我也无法在PHP中增加max_execution_time.
如何在Oracle上运行此程序或在没有超时的情况下使用PHP?请帮忙.
我在 DBA 堆栈交换的这个答案中非常全面地回答了如何使用 Oracle Scheduler 异步运行长时间运行的过程。请参阅https://dba.stackexchange.com/a/67913/38772
TL;DR 是
-- submit this as a background job
BEGIN
  dbms_scheduler.create_job ( 
      job_name => 'MY_BACKGROUND_JOB'
    , job_type => 'STORED_PROCEDURE'    
    , job_action => 'SP_GET_MY_DATA'
    , enabled => TRUE
    , auto_drop => TRUE
  );
END;
如果您想将参数传递给过程,您将需要做更多的工作。您可能会发现这个答案很有帮助https://dba.stackexchange.com/q/42119/38772/
有关所有详细信息的更多参考,Oracle 文档中的相关章节位于https://docs.oracle.com/database/121/ADMIN/scheduse.htm
| 归档时间: | 
 | 
| 查看次数: | 403 次 | 
| 最近记录: |