Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have two Qlikview documents :
- 1 document that loads and stores my qvd files
- Another document that uses this qvd files
But sometimes, there is a conflit because I try to store a qvd which is being used.
Is it possible to detect if a qvd file is already used before to store it?
Thanks and Regards
Sara
Hello,
Great thread! Thansk you, it helps a lot!!!
Here is my tested and approved code:
//Code to use in Qlikview document where the QVD is in use
LockFile:
LOAD * INLINE [
fileUsed
1
];
store LockFile into LockFile.txt(txt);
drop table LockFile;
FACT:
LOAD * FROM fact.qvd (qvd);
LockFile:
LOAD * INLINE [
fileUsed
0
];
store LockFile into LockFile.txt(txt);
drop table LockFile;
//Code to use in Qlikview document where the QVD is stored to test if the qvd is in use
FACT:
LOAD * FROM fact.qvd (qvd);
let flag = 0;
LockFile:
LOAD fileUsed as currLock FROM LockFile.txt
(txt, utf8, embedded labels, delimiter is '\t', msq);
let flag = peek('currLock');
Do while peek('currLock') = 1 //file is in use.
// Waiting for 5 seconds and test again
sleep 5000;
LockFile:
LOAD fileUsed as currLock FROM LockFile.txt
(txt, utf8, embedded labels, delimiter is '\t', msq);
loop;
STORE test into d_fact.qvd;
Thanks & Regards
Hello Sara,
in the Script, you can use the filetime() function to check if a file exists.
For example:
if isnull(filetime('c:\file.txt')) then
//file doesnt exists
else
//file exists
end if
Regards
tim
Hello and thank you for your response.
I don't want to know if the file exists but if it is already in use when I try to store it again.
Regards
Sara
sorry for that misunderstanding.
This thread could be helpful
ErrorMode = 0: File locked by another QlikView ... | Qlik Community
Hello,
Great thread! Thansk you, it helps a lot!!!
Here is my tested and approved code:
//Code to use in Qlikview document where the QVD is in use
LockFile:
LOAD * INLINE [
fileUsed
1
];
store LockFile into LockFile.txt(txt);
drop table LockFile;
FACT:
LOAD * FROM fact.qvd (qvd);
LockFile:
LOAD * INLINE [
fileUsed
0
];
store LockFile into LockFile.txt(txt);
drop table LockFile;
//Code to use in Qlikview document where the QVD is stored to test if the qvd is in use
FACT:
LOAD * FROM fact.qvd (qvd);
let flag = 0;
LockFile:
LOAD fileUsed as currLock FROM LockFile.txt
(txt, utf8, embedded labels, delimiter is '\t', msq);
let flag = peek('currLock');
Do while peek('currLock') = 1 //file is in use.
// Waiting for 5 seconds and test again
sleep 5000;
LockFile:
LOAD fileUsed as currLock FROM LockFile.txt
(txt, utf8, embedded labels, delimiter is '\t', msq);
loop;
STORE test into d_fact.qvd;
Thanks & Regards