【发布时间】:2018-04-23 17:58:59
【问题描述】:
我有一个从 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 而不会超时?请帮忙。
【问题讨论】:
-
使用 DBMS_SCHEDULER oracle 包将其作为程序运行
-
@OldProgrammer - 你能给我一个同样的例子吗?
-
没有。谷歌“oracle dbms_scheduler”并阅读文档。
标签: php oracle stored-procedures