CraZySacX / node-jdbc

JDBC Wrapper for node.js
140 stars 107 forks source link

Call stored procedure that return clob #182

Open syahiaoui opened 6 years ago

syahiaoui commented 6 years ago

Hi, I would like to call stoted function using teradata, and the result expected is Clob, but i got integer 0, or an empty array depending the function used; The stored function used: let sql = CALL DEV.MY_PROC(:data,OUT_RESULT)

callproc: (sql, options, cb) => {
    if (options === null || options === undefined) {
        options = {};
    }
    let pool = db.getPool();
    //get the connection
    pool.reserve((err, connObj) => {
        if (err) {
            logger.error(err);
            db.doRelease(pool, connObj);
            db.poolPurge(pool);
            cb({
                code: constError.INTERNAL_SERVER_ERROR,
                data: err
            }, null);
            return;
        }
        let connPool = connObj,
            connection = connObj.conn;
        connection.prepareCall(sql, (err, statement) => {
            if (err) {
                logger.error(err);
                db.doRelease(pool, connPool);
                db.poolPurge(pool);
                cb({
                    code: constError.METHOD_FAILURE,
                    data: err,
                }, null);
                return;
            }
            statement.executeUpdate(
                (err, results) => {
                    db.doCloseStatment(statement);
                    db.doRelease(pool, connPool);
                    if (err) {
                        logger.error(err);
                        cb({
                            code: constError.BAD_REQUEST,
                            message: err,
                        }, null);
                        return;
                    } else {
                        cb(null, results);
                    }
                });
        });
    })
}

The results is: { "results": 0 } More informations:

Nodejs: 10.0.0 NPM: 6.1.0 OS: Ubuntu Database: Teradata