简体   繁体   English

ORA-01036: 从 nodejs 运行 PL SQL 块时变量名称/编号非法

[英]ORA-01036: illegal variable name/number while running PL SQL block from nodejs

I have following pl/sql block:我有以下 pl/sql 块:

DECLARE
    user_name varchar(255);
    custom_exception EXCEPTION;
    PRAGMA exception_init( custom_exception, -20001);
BEGIN
    SELECT name 
    INTO user_name
    FROM data_table where ID = '1';
    
    IF user_name  = 'temp' THEN 
        RAISE custom_exception;
    END IF;
END;

When I run it from Oracle SQL Developer, it works fine.当我从 Oracle SQL Developer 运行它时,它工作正常。 But I am getting ORA-01036: illegal variable name/number while running it from nodejs.但是我在从 nodejs 运行它时收到 ORA-01036: illegal variable name/number。

Call from Nodejs code:从 Nodejs 代码调用:

var output = await connection.execute(fs.readFileSync('path_to_pl_sql_file', 'utf8'), {
    message: {
        dir: oracledb.BIND_OUT,
        type: oracledb.STRING,
        maxSize: 100
    }
}, {
    autoCommit: true
});

Can someone point out what going wrong here?有人可以指出这里出了什么问题吗?

The error was not with the PL/SQL block.错误与 PL/SQL 块无关。 I was passing in bind variables while executing the PL/SQL from nodejs and that bind variable was not present in the SQL. Hence the error!我在从 nodejs 执行 PL/SQL 时传递了绑定变量,并且该绑定变量不存在于 SQL 中。因此出现错误!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM