2016-10-14 7 views
0

良い日に、私は、SQLからいくつかのデータをエクスポートし、それを保存し、後でにそのデータを比較しようとしています、クエリ(Node.jsの&ノード-MSSQL)

をテーブル値パラメータ(TVP)を使用することができません。同じクエリの結果私がこれを行うために見ることができる最も簡単な方法は、TVPを使用することですが、node-mssqlでは動作しないようで、TVP関連のエラーは表示されません。

私は、コードを実行します。

var _sql = require('mssql'); 
var _conn = new _sql.Connection(/*CONN STR*/,function(err) { 
    if (err) { 
    console.log('ERROR Unable to connect to DB:',err); 
    } else { 
    var oInitRequest = new _sql.Request(_conn); 
    oInitRequest.query(/*DB QUERY*/) 
     .then(function(oInitRS) { 
     console.log('oInitData:',oInitRS); 
     var oInitTable = oInitRS.toTable(); 
     console.log('oInitTable:',oInitTable); 

     var oCheckRequest = new _sql.Request(_conn); 
     oCheckRequest.input('oInitTable',_sql.TVP,oInitTable); 
     oCheckRequest.query('SELECT * FROM @oInitTable') 
      .then(function(oCheckRS) { 
      console.log('oInitTable re-read:',oCheckRS); 
      }) 
      .catch(function(err) { 
      console.log('ERROR unable to pass oInitTable to new query',err); 
      }); 
     }) 
     .catch(function(err) { 
     console.log('ERROR Unable to retrieve oInitData',err); 
     }); 
    } 
}); 

私はエラーが表示されます。

ERROR unable to pass oInitTable to new query 
{ 
    [RequestError: Could not find stored procedure 'sp_executesql'.] 
    name: 'RequestError', 
    message: 'Could not find stored procedure \'sp_executesql\'.', 
    code: 'EREQUEST', 
    number: 2812, 
    lineNumber: 1, 
    state: 1, 
    class: 16, 
    serverName: /*REDACTED*/, 
    procName: '', 
    precedingErrors: [] 
} 

それは、最初のクエリのために成功にsp_executesqlを使用してクエリを実行することができたが、ストアドプロシージャが存在しなかったのはなぜ第二のために?

私はプリペアドステートメントを使用してみましたが、パラメータなしでさえも標準のものがエラーを知らせる動作しませんでした:

{ 
    [RequestError: Could not find prepared statement with handle 0.] 
    name: 'RequestError', 
    message: 'Could not find prepared statement with handle 0.', 
    code: 'EREQUEST', 
    number: 8179, 
    lineNumber: 1, 
    state: 4, 
    class: 16, 
    serverName: /*REDACTED*/, 
    procName: 'sp_execute', 
    precedingErrors: [] 
} 

誰もが、具体的ストアドプロシージャを作成することなく、TVPを受け入れるようにクエリを取得する方法を知っています1つのクエリのために?

+0

スクリプトの入力ミス(/ s/oRequest/oCheckRequest)のために編集されています。 – KaoSDlanor

答えて

0

謝罪。これはnode-mssqlのバグであり、助けられるものではないようです。

関連する問題