我有以下代码:
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 注入。
语句不绑定变量,我用数组表达式试过但是不行
谢谢。