Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
sarafamiglietti
Creator
Creator

How to detect if a QVD file is used before store it?

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

1 Solution

Accepted Solutions
sarafamiglietti
Creator
Creator
Author

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

View solution in original post

4 Replies
zhadrakas
Specialist II
Specialist II

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

sarafamiglietti
Creator
Creator
Author

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

zhadrakas
Specialist II
Specialist II

sorry for that misunderstanding.

This thread could be helpful

ErrorMode = 0: File locked by another QlikView ... | Qlik Community

sarafamiglietti
Creator
Creator
Author

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