Welcome Guest, Not a member yet? Register   Sign In
OCI8 driver fix for CI 1.6.3
#1

[eluser]Donny Kurnia[/eluser]
Currently I'm using CI for a project. I need to call stored procedure and stored function from Oracle database. I found many bug in the default oci8_driver. So, I attempt to fix it. I put the patch for oci8_driver.php and oci8_result.php in a zip file here:
http://www.mediafire.com/?xn9nzsxdvxh
or
http://drop.io/dmzlus7

I test it with this controller:
Code:
function index()
  {
    echo '<h1>Test</h1>'."<br/>\n";
    //$query = $this->db->query('select sysdate from dual');
    $this->db->select('sysdate');
    $query =& $this->db->get('dual');
    foreach ($query->result_array() as $row)
    {
      echo 'sysdate : '.$row['SYSDATE']."<br/>\n";
    }

    echo 'Calling stored procedure using fetch_stored'."<br/>\n";
    $curs = FALSE;
    $params = array (
      array ('name' => ':result', 'value' => &$curs, 'length' => -1, 'type' => OCI_B_CURSOR)
    );
    $result =& $this->db->fetch_stored('', 'P_CONTENT' , $params);
    echo '<pre>';
    var_dump($result);
    echo '</pre>';

    echo 'Calling stored function'."<br/>\n";
    $curs = FALSE;
    $return = array ('name' => ':result', 'value' => &$curs, 'length' => -1, 'type' => OCI_B_CURSOR);
    $params = FALSE;
    $this->db->stored_function('', 'F_CONTENT' , $return, $params);
    $this->db->execute_cursor();
    while ($data =& oci_fetch_row($this->db->curs_id)) {
      echo '<pre>';
      var_dump($data);
      echo '</pre>';
    }
  }

Here is the DDL for stored procedure and stored function that I call from above controller
Code:
CREATE OR REPLACE
PACKAGE RCURSOR
AS
  type tocursor is ref cursor;
end;

CREATE OR REPLACE
PROCEDURE P_CONTENT
    (prm_outcursor   out   RCURSOR.tocursor) IS
BEGIN
  open prm_outcursor for
    SELECT
          *
    FROM  
          TBL_CONTENT;
END P_CONTENT;

CREATE OR REPLACE
FUNCTION F_CONTENT RETURN RCURSOR.tocursor AS
prm_outcursor RCURSOR.tocursor;
BEGIN
  open prm_outcursor for
    SELECT
          *
    FROM  
          TBL_CONTENT;
  RETURN prm_outcursor;
END F_CONTENT;

Thanks to all suggestion in these topics:
http://ellislab.com/forums/viewthread/72707/
http://ellislab.com/forums/viewthread/80943/
http://ellislab.com/forums/viewthread/80004/
http://ellislab.com/forums/viewthread/74105/#368167
#2

[eluser]ENG.Helewa[/eluser]
Thank you very much ..
but i want to ask how to perform this fixation?
is there any tool to perform that?
if not could you please provide us the full fixed files?

thanks in advance.




Theme © iAndrew 2016 - Forum software by © MyBB