See Qlik Inline Loading for help on understanding INLINE loads

Meant to be paired with:

SUB CheckLogFileExists(mRecreate)
/*
	Assumes:
	- vLoaderLogFileLocation is a variable in memory that represents the location of a QVD Loader Log file with the following columns:
		- ID
		- RunID
		- Process
		- App
		- Section
		- Type
		- TaskName
		- TaskStart
		- TaskEnd
		- Log_Message
		- User
		- Tags
 
	Args:
	- mRecreate - Assumed to be either 1 or 0. 1 to force a re-creation of the table. 0 to NOT delete existing table and start over
	
	Returns:
	- rRunID - To be stored in mmeory to be referenced in WriteToLogFile, seto to 1 if the table is being re-created
*/
 
	LET vStart = TimeStampe(Now());	
 
	// FileSize() as a method will return NULL if a file does NOT exist
	IF mRecreate = 1 OR IsNull(FileSize(vLoaderLogFileLocation)) THEN
 
		TRACE $(vLoaderLogFileLocation) is being created;
 
		zLoaderLog:
		LOAD *
		INLINE [
			ID,RunID,Process,App,Section,Type,TaskStart,TaskEnd,Log_Message,User,Tags
			1,1,META,,,,$(vStart),$(vEnd),Logging QVD Created,Username,
		];
 
		STORE zLoaderLog INTO $(vLoaderLogFileLocation);
 
		DROP TABLE zLoaderLog;
 
		SET vRunID = 1;
 
	ELSE
	
		TRACE $(vLoaderLogFileLocation) already exists, skipping creation and assigning vRunID;
 
		zLoaderLog:
		LOAD
			RunID
		FROM [$(vLoaderLogFileLocation)] (QVD);
 
		// -1 in the second argument represents the 'bottom' record of the table, as in the most recent addition to the logging table
		LET vMaxID = PEEK('RunID',-1,'zLoaderLog');
 
		LET vRunID = vMaxID + 1;
 
		DROP TABLE zLoaderLog;
 
	ENDIF
 
END SUB;