Node - Oracle 准备语句不绑定通配符

问题描述 投票:0回答:0

我有以下代码:

     async test() {
        let conn = null;
        try  {
            conn = await this.connect();

            debug("connection!")

            const SQLstatement = `SELECT * FROM :id`

            const table = 'protocol';
            const response = await conn.execute(SQLstatement, {
                id: { dir: oracledb.BIND_IN, val: table , type: oracledb.STRING }
            });
            conn.commit()

            return response;
        } catch (e) {
            throw e;
        } finally {
            conn.close();
        }
    }

这是一个测试,它已经适用于字符串连接,但我必须避免 SQL 注入。

语句不绑定变量,我用数组表达式试过但是不行

谢谢。

javascript node.js oracle sql-injection node-oracledb
© www.soinside.com 2019 - 2024. All rights reserved.