How to pass ROWNUM dynamically in LS command line argument

Hi,

I want to pass a dynamic parameter like ROWNUM in the command line argument so, that the relevant query can fetch the number of rows based on that. Is this achievable ?
I am using Windows 10. Kindly help.

Below the config snippet that I am using and working. Here ROWNUM is mentioned inside the query whereas I want it to be passed dynamically not as a jdbc parameter which we can mention in the configuration file itself.

input {
		 
		jdbc {
			jdbc_connection_string => "jdbc:db2://10.110.131.187:60006/STERCLD"
			jdbc_user => "db2prod"
			jdbc_password => "db2pr0d"
			jdbc_validate_connection => true
			jdbc_driver_library => "D:\Cognizant - OneDrive\OneDrive - Cognizant\LT027695\D\Software\db2jars\db2jcc.jar"
			jdbc_driver_class => "com.ibm.db2.jcc.DB2Driver"
			statement => "SELECT CAST(SUBSTR(ORDER_HEADER_KEY,1,14) AS BIGINT) AS order_header_key, 
							DOCUMENT_TYPE,ENTRY_TYPE,ORDER_NO, ORDER_DATE, TOTAL_AMOUNT, PAYMENT_STATUS
							FROM AWS_STER_SCH.YFS_ORDER_HEADER
							WHERE CAST(SUBSTR(ORDER_HEADER_KEY,1,14) AS BIGINT) >:sql_last_value						
							AND CREATETS > (CURRENT DATE - 0 DAYS)
							AND DOCUMENT_TYPE='0001'
							AND ROWNUM BETWEEN 0 AND  500
							ORDER BY ORDER_HEADER_KEY"
			
			use_column_value => true
			tracking_column => "order_header_key"
			tracking_column_type => "numeric"
			last_run_metadata_path => "D:\logstash-6.6.0\logstash-6.6.0\Logstash_Anupam_Scripts\.logstash_jdbc_last_run"
			record_last_run => true
			schedule => "* * * * *"
			#use_column_value => true
			#tracking_column => "Order_No"
			#last_run_metadata_path => "D:\logstash-6.5.1\Logstash_Samant_Scripts\.logstash_jdbc_last_run"
			# sql_last_value  use in  where clause as :  WHERE Order_No > :sql_last_value


		}	
	 
	
}

filter {
	
	mutate { remove_field => ["@version"] }

}
		
output {
	stdout {
		codec => rubydebug
	}

	elasticsearch {
		hosts => "localhost"
		index => "orders"
		document_id => "%{[order_header_key]}"

 	}
}

You cannot pass it on the command line, but you might be able to use an environment variable.

Thank you for sharing this valuable information.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.