I recognized an issue with action 'SQL Query to CSV file'.
I want to create a CSV file from sql data and then (if it exists) send it to an email-address.
I am using for example {TempDir}\test.csv as target file for the query results.
In the first run I have a result set and the email is sent with the correct CSV file in attachement.
The second run does have an empty result set but the email is sent with the file from the first run.
I checked 'Do not create file if query result is empty' but I assumed that files in temporary folder are deleted after the task ends properly.
I do not want to send empty files.
I also check if the file exists with '{FileExists({TempDir}\test.csv)}'. In my opinion this check should not find the file in the second run.
Code: Select all
I: 13.06.2025 08:34:50: ****** Starting task: Test TEMP Datei ******************
I: 13.06.2025 08:34:50: Executing "1.SQL Query to CSV File"
I: 13.06.2025 08:34:50: Executing "2.If Then"
I: 13.06.2025 08:34:50: Executing "3.SMTP Send Email"
I: 13.06.2025 08:34:50: Executing "4.Else"
I: 13.06.2025 08:34:50: Task executed successfully
I: 13.06.2025 08:35:14: ****** Starting task: Test TEMP Datei ******************
I: 13.06.2025 08:35:14: Executing "1.SQL Query to CSV File"
W: 13.06.2025 08:35:14: The query returned an empty recordset
I: 13.06.2025 08:35:14: Executing "2.If Then"
I: 13.06.2025 08:35:14: Executing "3.SMTP Send Email"
I: 13.06.2025 08:35:14: Executing "4.Else"
I: 13.06.2025 08:35:14: Task executed successfully
RoboTask version 10.4.0.1192 (x64 edition)
Assembly version 10.4.0.316
This is my task:
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1199727700
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task41"
Hide=INTEGER|0
ID=INTEGER|-541250406
LogOnAsUser=INTEGER|1
Name=STRING|"Test TEMP Datei"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RestrictRESTAPIAccess=INTEGER|0
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
StepPause=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
[Actions\Action1]
ActionID=STRING|"A_CSVFROMSQL"
Enabled=INTEGER|-1
Name=STRING|"SQL Query to CSV File"
Params=FOLDER
[Actions\Action1\Params]
connectionstring=STRING|"Provider=SQLOLEDB.1;Password=;Persist Security Info=True;User ID=;Initial Catalog=;Data Source="
customdateformat=STRING|"0"
dateformat=STRING|"yyyy-mm-dd hh:nn:ss"
delimiter=STRING|"2"
limitlength=STRING|"999"
notcreateifempty=STRING|"1"
override=STRING|"0"
paramcount=STRING|"0"
password=STRING|""
quotechar=STRING|"0"
sql=STRING|""
strictdelimiter=STRING|"1"
targetencoding=STRING|"0"
targetfilename=STRING|"{TempDir}\test.csv"
timeout=STRING|"60"
usefieldnames=STRING|"1"
uselimitlength=STRING|"1"
withmemo=STRING|"1"
[Actions\Action2]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER
[Actions\Action2\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{FileExists({TempDir}\test.csv)}"
[Actions\Action3]
ActionID=STRING|"A_INET_SENDMAIL"
Enabled=INTEGER|-1
Name=STRING|"SMTP Send Email"
Params=FOLDER
[Actions\Action3\Params]
attach0=STRING|"{TempDir}\test.csv"
attachcount=STRING|"1"
auth=STRING|"0"
charset=STRING|"windows-1250"
from=STRING|""
host=STRING|""
html=STRING|"1"
msg0=STRING|"<html>"
msg1=STRING|"<body>"
msg8=STRING|"</body>"
msg9=STRING|"</html>"
msgcount=STRING|"10"
password=STRING|""
port=STRING|""
priority=STRING|"1"
receipt=STRING|"0"
SSL=STRING|"0"
subject=STRING|"Test"
tlsmode=STRING|"0"
tlsver=STRING|"2"
to=STRING|""
user=STRING|""
xmailer=STRING|"RoboTask"
[Actions\Action4]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"
[Actions\Action5]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER
[Actions\Action5\Params]
message=STRING|"Keine Daten vorhanden"
type=STRING|"3"
[Actions\Action6]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"