2016-05-28 11 views
1

私はこのテーブルにクローブ列を持っています。 oracledbドライバを使ってExpressアプリケーションからデータベースに接続します。私はこのクローブを印刷したい。これは私のコードです:Clobが明示的なアプリケーションで正しく印刷されていない

router.get('/:task_name', function (req,res) { 
"use strict"; 

oracledb.getConnection(connAttrs.database, function (err, connection) { 
    if (err) { 
     // Error connecting to DB 
     res.set('Content-Type', 'application/json'); 
     res.status(500).send(JSON.stringify({ 
      status: 500, 
      message: "Error connecting to DB", 
      detailed_message: err.message 
     })); 
     return; 
    } 

    connection.execute("select solution from solvedtasks s join tasks t on t.TASK_ID = s.TASK_ID WHERE task_name= :task_name", [req.params.task_name],{ 
     outFormat: oracledb.OBJECT //resultSet:true, 

    }, function (err, result) { 
     if (err) { 
      res.set('Content-Type', 'application/json'); 
      res.status(500).send(JSON.stringify({ 
       status: 500, 
       message: "Error getting the user profile", 
       detailed_message: err.message 
      })); 
     } else { 
      res.contentType('application/json').status(200); 
      res.send(JSON.stringify(result.rows[0])); 
      console.log(result.rows[0]); 
      // fetchRowsFromRS(connection,res,result.resultSet,10); 
     } 
     // Release the connection 

     connection.release(
      function (err) { 
       if (err) { 
        console.error(err.message); 
       } else { 
        console.log("GET /SolvedTasks : Connection released"); 
       } 
      }); 

    }); 
    }); 
}); 

私のデータベースからclobを印刷する代わりに、私はロブメタデータのように見えます。他の誰かがこの問題に遭遇しましたか?ここに私の出力のスクリーンショットがあります: Clob output

答えて

1

私はこれを解決しましたので、誰かがこの問題を抱えている場合に備えて回答を投稿しています。明らかにオリジナルのoracledbドライバにはclobを処理するいくつかの問題があります。しかし、そこにその機能を拡張ライブラリは、ある使用してインストールすることは非常に簡単、シンプル-ORACLEDB呼ば:https://github.com/sagiegurari/simple-oracledb

connection.queryを使用して、CLOBのが適切に処理されています

enter code here 
connection.query('SELECT * FROM departments WHERE manager_id > :id', [110],  { 
    splitResults: true, //True to enable to split the results into bulks, each bulk will invoke the provided callback (last callback invocation will have empty results) 
    bulkRowsAmount: 100 //The amount of rows to fetch (for splitting results, that is the max rows that the callback will get for each callback invocation) 
}, function onResults(error, results) { 
    if (error) { 
    //handle error... 
    } else if (results.length) { 
    //handle next bulk of results 
    } else { 
    //all rows read 
    } 
}); 
関連する問題