Welcome Guest! Log in
×

Notice

The forum is in read only mode.
Due to some maintenance operations, stambia.org will be switched to read-only mode during the 13th November. It will be possible to read and download, but impossible to post on the forums or create new accounts. For any question please contact the support team.

Topic-icon Question check flat file contain any records or not

More
16 Nov 2016 15:22 #1 by Prashant.Sangle
Prashant.Sangle created the topic: check flat file contain any records or not
Hi,

I want to check that file contain records or not, before move action perform.
If 0 records then send alert mail else proceed to next action.

Regards,
Prashant
More
16 Nov 2016 17:14 - 16 Nov 2016 17:18 #2 by Cyril Dussud
Cyril Dussud replied the topic: check flat file contain any records or not
Hi,

I see different solutions to perform this:

1. If your file is supported by Stambia (Delimited/Positional, ...) you could simply perform a select on the file with a SQL Operation and check the number of results through a bind link.
For instance:


-> The caveat of this is that all the rows of the files are read

2. You could also make a little script that test the length of the file
For instance:


In this example, we are testing that the file exists, and then its length.
The script is:
File file = new File("${../filePath}$");

if (file.exists()) {
	if (file.length() == 0){
		__ctx__.publishVariable("~/fileStatus","EMPTY");
	}
	else{
		__ctx__.publishVariable("~/fileStatus","NOT_EMPTY");
	}
}else{
	__ctx__.publishVariable("~/fileStatus","NOT_EXISTS");
}

We are using then the variable we have published to split our Process, with conditions like
"${~/fileStatus}$" == "EMPTY"

I hope this answers to your question.:)
Attachments:
Last Edit: 16 Nov 2016 17:18 by Cyril Dussud.