Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Retrieving CLOB data field from Oracle
#1

[eluser]fszostak[/eluser]
Hi All!

After migration MySQL to Oracle, any fields with LONGTEXT datatype was change for CLOB datatype.

1) Error "Object of class OCI-Lob could not be converted to string" on field N.CONTENT (CLOB)

Code:
function getNews() {
      $this->db->select("
        N.ID AS ID
      , N.TITLE
      , N.CONTENT AS CONTENT
      ", FALSE);
      $this->db->from("TB_NEWS N");
      $this->db->order_by("N.DATETIME", "DESC");
      $query = $this->db->get();
      return $query->result();
   }
}

2) Convert N.CONTENT to char... but received another error.

Code:
SELECT
  N.ID
, N.TITLE
, TO_CHAR(N.CONTENT) AS CONTENT   <= this CLOB field
FROM
  TB_NEWS N
ORDER BY N.DATETIME DESC

Error:
ORA-22835:Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 6922, maximum: 4000)


Please help me!!!! :-D
#2

[eluser]fszostak[/eluser]
I found the solution in this thread http://ellislab.com/forums/viewthread/108172/#545496
Then i did create function to help.

Code:
function read_clob($field) {
    return $field->read($field->size());
}




Theme © iAndrew 2016 - Forum software by © MyBB