本文主要是介绍Qlik Sense : Store With Retry (保存重试机制),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Background
sometime you cannot store the file directly ,maybe there are another process are reading/storeing the file , so you would need to wait another proecess done and retry . then we come up this solution .
有时您不能直接存储文件,可能还有另一个进程正在读取/存储文件,所以您需要等待另一个过程完成并重试。然后我们提出了这个解决方案。
with Lukasz BOS . by zhengkai.blog.csdn.net
mind : add a while true loop , try store the file , if error then sleep 2s and retry till completed .添加一段真循环,尝试存储文件,如果错误,然后睡眠2s,重试直到完成。
Show me the code
//by zhengkai.blog.csdn.net
//Ocassionally storing may fail because of multiple tasks try to store the progress of processed groupsSET ErrorMode=0;Set ScriptErrorCount = 0;DO WHILE TRUE()store intraday_missing_record into [lib://xxxxxx/_Latest_Intraday.qvd] (qvd);IF $(ScriptErrorCount) = 0 THENEXIT DOELSEsleep(2000); //wait for a secondSet ScriptErrorCount = 0; END IFLOOPSET ErrorMode=1;
Package as a SUB
//by zhengkai.blog.csdn.net
SUB Store_With_Retry(vs_tableName,vs_filePath,vs_fileType)//Ocassionally storing may fail because of multiple tasks try to store the progress of processed groups, so//ignore if any errorSET ErrorMode=0;//get error from the counterSet ScriptErrorCount = 0;DO WHILE TRUE()Store $(vs_tableName) into [$(vs_filePath)] ($(vs_fileType));IF $(ScriptErrorCount) = 0 THENEXIT DOELSEsleep(1000); //wait for a secondSet ScriptErrorCount = 0;END IFLOOP//set back to normal mode , stop if any errorSET ErrorMode=1;END SUB
ErrorMode
参数 | 说明 |
---|---|
ErrorMode=1 | 默认设置。脚本执行会暂停,并且会提示用户进行操作(非批量模式)。 The default setting. The script execution will halt and the user will be prompted for action (non-batch mode). |
ErrorMode =0 | Qlik Sense 只需忽略故障,并继续在下一个脚本语句上执行脚本。 Qlik Sense will simply ignore the failure and continue script execution at the next script statement. |
ErrorMode =2 | 一旦出现错误,Qlik Sense 会立即触发“脚本执行故障...”错误信息,但不会提示用户预先进行操作。 Qlik Sense will trigger an "Execution of script failed..." error message immediately on failure, without prompting the user for action beforehand. |
Sleep
Argument | Description |
---|---|
n | Stated in milliseconds, where n is a positive integer no larger than 3600000 (i.e. 1 hour). The value may be an expression. 以毫秒为单位表示,其中 n 是一个正整数,且不得大于 3600000(即 1 小时)。该值也可以是一个表达式。 |
这篇关于Qlik Sense : Store With Retry (保存重试机制)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!