/
3-create-logger-view.sql
39 lines (29 loc) · 1.16 KB
/
3-create-logger-view.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-- Description:
-- Create a view to save logs
@logs = select
'Equity' as [Instrument],
0 as [WriteErrorCode];
@create_logger_view = use Sys.Admin.SetupView with @logs
--provider=ETL_Manager.Save_Logs_To_Drive
--description="This is a tool for saving logs"
--parameters
LogsLocation,Text,"luminesce-examples/orchestration/logs",true
LogFileName,Text,"instrument_log_load",true
Logs,table,@logs,true
----
--@logs = select #PARAMETERVALUE(Logs);
@@logsLocation = select #PARAMETERVALUE(LogsLocation);
@@logFileName = select #PARAMETERVALUE(LogFileName) || strftime('%Y%m%d_%H%M%S', datetime());
@errorsFromLoad = select * from
#PARAMETERVALUE(Logs) where WriteErrorCode<>0;
@@errorCount = select count(*) from @errorsFromLoad;
@saveFilesToDrive = use Drive.SaveAs with @errorsFromLoad, @@logsLocation, @@logFileName
--path=/{@@logsLocation}
--ignoreOnZeroRows=true
--fileNames={@@logFileName}
enduse;
@@throwErrorOnError = select iif(@@errorCount > 0,
print('The load has partially failed with errors'), "File loaded successfully"); --change "print" to "throw"
select * from #PARAMETERVALUE(Logs);
enduse;
select * from @create_logger_view;