Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
ioannaiogr
Creator II
Creator II

error in script to empty a qvd file

Hi all.

Please help me out with this. I've seen on the forum this code that helps truncate the existing qvd data, but I'm facing errors.

I'm pasting what I'm doing, error says table _TableStructure cannot be found.

SUB EmptyQVD (['lib://my_connection'/MyQVD.qvd])
//Check file exists


IF (NOT isNull(qvdCreateTime(['lib://my_connection'/MyQVD.qvd]))) THEN
//Check if QVD is already empty


IF (qvdNoOfRecords(['lib://my_connection'/MyQVD.qvd]) > 0) THEN


//Load the structure from the existing QVD
//Where clause returns no records


_TableStructure:
LOAD
*
FROM ['lib://my_connection'/MyQVD.qvd] (qvd)
WHERE 1<>1;

//Store table definition back to QVD


STORE _TableStructure INTO ['lib://my_connection)'/MyQVD.qvd] (qvd);
DROP TABLE _TableStructure;
END IF
END IF
END SUB

 

Your help is , as always, so valuable 🙂 Thank you in advance

Labels (2)
6 Replies
ioannaiogr
Creator II
Creator II
Author

Anyone, please? 

MayilVahanan

HI 

Try like below


set vPath = 'lib://my_connection/';


SUB EmptyQVD(QVDNameWithPath)
//Check file exists

TRACE QVDNameWithPath - $(QVDNameWithPath);

IF (NOT isNull(qvdCreateTime(QVDNameWithPath))) THEN
//Check if QVD is already empty


IF (qvdNoOfRecords(QVDNameWithPath) > 0) THEN


//Load the structure from the existing QVD
//Where clause returns no records


_TableStructure:
LOAD
*
FROM $(QVDNameWithPath) (qvd)
WHERE 1<>1;

//Store table definition back to QVD


STORE _TableStructure INTO $(QVDNameWithPath)(qvd);
DROP TABLE _TableStructure;
END IF
END IF
END SUB

Call EmptyQVD('[$(vPath)MyQVD.qvd]');

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
ioannaiogr
Creator II
Creator II
Author

Hello @MayilVahanan 🙂 Thanks for helping!

I'm not getting it correctly, let's say for example this:

TRACE QVDNameWithPath - $(QVDNameWithPath);

would be 

TRACE ['lib://my_connection'/MyQVD.qvd] - $(['lib://my_connection'/MyQVD.qvd]);

 

?

 

charishma01
Contributor
Contributor

remove drop table
ioannaiogr
Creator II
Creator II
Author

errors.png

 

@MayilVahanan see, I'm getting all these reds... I've been on it all day, still I can't find what this error is! 

 

MayilVahanan

HI 

You can't write values in the sub function, However you can pass the value.

Did you try the code suggested already?

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.