Execute dbms_mview.refresh from CodeIgniter

送分小仙女□ 提交于 2019-12-12 05:19:55

问题


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\')');

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!


回答1:


Well, I've never heard of CodeIgniter before, but my educated guess is that you're using $this->$db->query and you're not passing it a query?

My guess would be, if it supports calling stored procedures at all, perhaps there's a $this->$db->call_function or $this->$db->call_procedure, or something?

Sorry, this is really a Codeigniter question, not an Oracle question.




回答2:


Well, it looks like I finally managed to solve the problem. I'm posting my solution, maybe it might help someone else.

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:

In the model:

...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);

And it worked!

Cheers, Vero



来源:https://stackoverflow.com/questions/7825969/execute-dbms-mview-refresh-from-codeigniter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!