Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
- I had taken a table from database and created a qvd file for particular table. The qvd and table has same number of rows. Now i want to update qvd file if i inserted some records in the database. For that i written a script as follows:
//Test:
//LOAD Id,
// Sname,
// Sal;
//SQL SELECT *
//FROM QvdUpdate.dbo.Test;
//STORE Test into Test.qvd;
TestFile:
SQL SELECT Id,
Sal,
Sname
FROM QvdUpdate.dbo.Test where id > 7;
Concatenate
LOAD Id,
Sname,
Sal
FROM
Test.qvd
(qvd);
STORE TestFile into Test.qvd;
- The qvd is Updating with this code. But in the sql statement i have given the conditon manually with the value i.e 7.
- In the place of 7 i want to put max(id)(i.e the last record value of the qvd file) value which is coming from qvd file.
hi,
give the following code a try. This is how I do it.
// first read from qvd and find max id
loadData:
LOAD Id,
Sname,
Sal
FROM
Test.qvd
(qvd);
maxId:
select max(Id) as maxId
resident loadData;
let vmaxId=peek('maxId',-1,maxId);
drop table maxId;
// now do a concatenate laod frolm your databse for everything above the maxId
loadData:
Concatenate (loadData)
LOAD Id,
Sname,
Sal;
loadData:
SQL SELECT Id,
Sal,
Sname
FROM QvdUpdate.dbo.Test where id > $(vmaxId);
STORE loadData into Test.qvd;