从CodeIgniter执行dbms_mview.refresh [英] Execute dbms_mview.refresh from CodeIgniter
问题描述
我需要执行EXECUTE dbms_mview.refresh('MATERIALIZED_VIEW_NAME')
从模型中调用此程序包,但是当我尝试使用这样的语句来执行此操作时:
I need to execute EXECUTE dbms_mview.refresh('MATERIALIZED_VIEW_NAME')
calling this package from the model but when I try to do it with a statement like this one:
$refresh = $this->db->query('EXECUTE DBMS_MVIEW.REFRESH(\'CRM_LISTADO_CONTACTOS\')');
但是我从模型中的这一行收到数据库错误.我也尝试过使用db->store_procedure
,但是它也不起作用.
But I receive a database error from this line in the model. I've also tried with db->store_procedure
but it didn't work either.
任何线索如何调用包裹? 非常感谢!
Any clue how to call a package? Thanks a lot!
推荐答案
好吧,看来我终于设法解决了这个问题.我正在发布解决方案,也许可能会对其他人有所帮助.
Well, it looks like I finally managed to solve the problem. I'm posting my solution, maybe it might help someone else.
在解析传递给过程的参数时,CI似乎崩溃了,因此,我不得不回到源头并使用基本的oci_execute方法.我的解决方案如下所示:
It looks like CI crashes when parsing the parameters passed to the procedure so, I had to go back to the sources and use the basic oci_execute method. My solution looks like this:
在模型中:
...执行插入和更新的代码...然后...
...code that executes INSERTS and UPDATES...then...
$p_name_mat_view = 'VIEW_NAME';
$p_refresh_method = NULL;
$conn = oci_connect('username', 'password', 'hostname');
$query = 'BEGIN dbms_mview.refresh(:p_name_mat_view, :p_refresh_method); END;';
$stid = oci_parse($conn, $query);
oci_bind_by_name($stid, ":p_name_mat_view", & $p_name_mat_view);
oci_bind_by_name($stid, ":p_refresh_method", & $p_refresh_method);
$r = oci_execute($stid);
它奏效了!
干杯, 维罗
这篇关于从CodeIgniter执行dbms_mview.refresh的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!