最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

而通过运行一个的NodeJS子查询的SQL命令无法正常结束

IT培训 admin 11浏览 0评论

而通过运行一个的NodeJS子查询的SQL命令无法正常结束

我想这个子查询获取表中的所有存在的列

我打电话给我的这些参数代码

let idsquery="select COLUMN_Name from ids_columns where table_id = (select table_id from ids_tables where table_name ='ZR_INVOICE_DETAILS');";
idsFunction(idsquery,icallback);

这里是我的代码

const oracledb = require('oracledb');
const idsObj=require('../config').idsObj;
let error;
let user;
function idsconnection(query,callback){
  // var query="select COLUMN_Name from ids_columns where table_id=2016";
  console.log(query);
  oracledb.getConnection(
      idsObj,
      function(err, connection) {
        if (err) {
          console.log('failed to connect',err);
          error = err;
          return;
        }
        connection.execute(query, [], function(err, result) {
          if (err) {
            console.log('failed to execute',err);
            error = err;
            return;
          }
          // console.log('column names are',result.metaData);
          // console.log('rows are',result.rows);
          // console.log('rows count is',result.rows.length);

          connection.close(function(err) {
            if (err) {
              console.log('failed to close connection',err);
            }
            // console.log('callback is ',callback);
            callback(result)
          });
        })
      }
  );
}

module.exports=idsconnection;

此代码工作正常,当我把它叫做

let idsquery="select COLUMN_Name from ids_columns where table_id = 2012;";
idsFunction(idsquery,icallback);

像这样

但是当我执行第一个查询它给这个错误

failed to execute { [Error: ORA-00933: SQL command not properly ended] errorNum:933, offset: 125 }
回答如下:

作为在评论中提及了由@亚历克斯 - 普尔,这个问题(或一期)将是你在声明尾随分号:

let idsquery="select COLUMN_Name from ids_columns where table_id = (select table_id from ids_tables where table_name ='ZR_INVOICE_DETAILS');";

将其更改为:

let idsquery="select COLUMN_Name from ids_columns where table_id = (select table_id from ids_tables where table_name ='ZR_INVOICE_DETAILS')";

甲骨文的SQL不包括分号。令人困惑的是,需要为PL / SQL分号,并且也用于SQL通过SQL * Plus一样一些工具说“这是语句的结束,之前执行这里的一切。”

而通过运行一个的NodeJS子查询的SQL命令无法正常结束

我想这个子查询获取表中的所有存在的列

我打电话给我的这些参数代码

let idsquery="select COLUMN_Name from ids_columns where table_id = (select table_id from ids_tables where table_name ='ZR_INVOICE_DETAILS');";
idsFunction(idsquery,icallback);

这里是我的代码

const oracledb = require('oracledb');
const idsObj=require('../config').idsObj;
let error;
let user;
function idsconnection(query,callback){
  // var query="select COLUMN_Name from ids_columns where table_id=2016";
  console.log(query);
  oracledb.getConnection(
      idsObj,
      function(err, connection) {
        if (err) {
          console.log('failed to connect',err);
          error = err;
          return;
        }
        connection.execute(query, [], function(err, result) {
          if (err) {
            console.log('failed to execute',err);
            error = err;
            return;
          }
          // console.log('column names are',result.metaData);
          // console.log('rows are',result.rows);
          // console.log('rows count is',result.rows.length);

          connection.close(function(err) {
            if (err) {
              console.log('failed to close connection',err);
            }
            // console.log('callback is ',callback);
            callback(result)
          });
        })
      }
  );
}

module.exports=idsconnection;

此代码工作正常,当我把它叫做

let idsquery="select COLUMN_Name from ids_columns where table_id = 2012;";
idsFunction(idsquery,icallback);

像这样

但是当我执行第一个查询它给这个错误

failed to execute { [Error: ORA-00933: SQL command not properly ended] errorNum:933, offset: 125 }
回答如下:

作为在评论中提及了由@亚历克斯 - 普尔,这个问题(或一期)将是你在声明尾随分号:

let idsquery="select COLUMN_Name from ids_columns where table_id = (select table_id from ids_tables where table_name ='ZR_INVOICE_DETAILS');";

将其更改为:

let idsquery="select COLUMN_Name from ids_columns where table_id = (select table_id from ids_tables where table_name ='ZR_INVOICE_DETAILS')";

甲骨文的SQL不包括分号。令人困惑的是,需要为PL / SQL分号,并且也用于SQL通过SQL * Plus一样一些工具说“这是语句的结束,之前执行这里的一切。”

发布评论

评论列表 (0)

  1. 暂无评论