问题
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