Search code examples
zend-frameworkblobclob

Zend: Inserting Large data in CLOB and BLOB?


I am pulling data from Google Places API and trying to insert reviews into oracle database using zend framework. But reviews that are very long are giving error like :

ORA-01461: can bind a LONG value only for insert into a LONG

When i try to run the insert query in Orqcle SQL Developer its giving the following error:

enter image description here

I tried some of the solutions i got on google and stackoverflow but still not working.

Here is my db code in zend:

public function addReview($bind) {

    $bind['STATUS'] = 1;
    $bind['CREATED_TIME'] = $this->_curDate;

    $text = htmlentities($bind['TEXT']);

    $query = "Insert INTO ".$this->_name." (LID,AUTHOR_NAME,AUTHOR_URL,RATINGS,TYPE,TIME,STATUS,TEXT) 
              VALUES (".$bind['LID'].",
                        '".$bind['AUTHOR_NAME']."',
                        '".$bind['AUTHOR_URL']."',
                        '".$bind['RATINGS']."',
                        '".$bind['TYPE']."',
                        '".$bind['TIME']."',
                        ".$bind['STATUS'].",'".$text."')"; 


    try {
        $insert = $this->_dbAdpt->query($query);
    } catch (Exception $e) {
        echo $query; exit;
    }

}

Solution

  • Somehow creating a procedure for inserting the reviews worked! Below is the procedure :

    create or replace procedure google_review (lid in int,author_name in varchar2, author_url in varchar2,ratings in varchar2,
    type in varchar2,time in varchar2,status int,text in varchar2)
    as
    begin
    
    INSERT INTO TBL_REVIEWS
      (
        LID,
        AUTHOR_NAME,
        AUTHOR_URL,
        RATINGS,
        TYPE,
        TIME,
        STATUS,
        TEXT
      )
      VALUES
      (
        LID,
        AUTHOR_NAME,
        AUTHOR_URL,
        RATINGS,
        TYPE,
        TIME,
        STATUS,
        TEXT
      );
      end;