Here is the query I had put in the logstash conf file:
select a.ID, a.TransactionID, b.Result
from MyDB.Result a inner join MyDB.ResultData b on a.ID=b.ID
where a.ID < :sql_last_value and a.CreatedOn > '2020-01-01'
order by a.ID
This is warning I get:
[2020-06-22T11:29:01,084][ERROR][logstash.inputs.jdbc ][main][c453478trgergy8gh78og6ogy8wef7834g78o9b5] Exception when executing JDBC query {:exception=>#<Sequel::DatabaseError: Java::ComMicrosoftSqlserverJdbc::SQLServerException: The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified.>}
This is the line listed:
SELECT TOP (1) count(*) AS [COUNT] FROM (select a.ID, a.TransactionID, b.Result from MyDB.Result a inner join MyDB.ResultData b on a.ID=b.ID where a.ID < 100000 and a.CreatedOn > '2020-01-01' order by a.ID) AS [T1]
I removed the inner join and just put in a simple select statement but still it is not working with the ORDER BY clause.
Without ORDER BY, the whole logic will fail.
As per this thread, ORDER BY should fine.
Is it something to do with the Microsoft SQL server which is my source database?
Logstash version: 7.7.0
SQL server version: Microsoft SQL Server 2014 (SP2-CU1) (KB3178925) - 12.0.5511.0 (X64) Aug 19 2016 14:32:30 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 6.3 (Build 9600: ) (Hypervisor)
EDIT
Just went through this thread.
Looks like he got around this issue by specifying
SELECT TOP 638858
Somehow I feel it is not the optimum solution.