0
私はSqlサーバを使用しています。node.jsには、特定のテーブルに新しい行が挿入されるたびに実行したい機能があります。Sqlサーバに挿入時にnode.js関数を呼び出す
これは、テーブルに変更が加えられたときに実行したいコードです。
private sql = require('mssql');
private currentID: any;
`private config = {
user: 'sa',
password: 'sa',
server: '192.168.100.2',
port: '1433',
database: 'test1',
connectionTimeout: 100000,};
`
public checkDatabase() {
this.sql.connect(this.config).then((connection: any) => {
new this.sql.Request(connection).query('SELECT EventID FROM Events ORDER BY EventID DESC').then((recordset: any) => {
console.log(recordset.recordset[0].EventID);
if (this.currentID == recordset.recordset[0].EventID) {
console.log("They are the same " + this.currentID + " " + recordset.recordset[0].EventID);
}
else {
console.log("Not the same " + this.currentID + " " + recordset.recordset[0].EventID);
}
this.currentID = recordset.recordset[0].EventID;
});
});
}
お願いします。
あなたがすべきinsert triggerを作成する –
一般的に不可能です。行がアプリケーションから挿入された場合、通知を受ける方法はありません。あなたはすべての保存関数のためのデコレータを作成しようとすることができます。 – StanislavL
@JúliusMarkoあなたは私に詳細を教えてください、私は多くのトリガーについてはよくわかりません – DavidS