on ‎2024 Jul 04 7:39 AM
I need to retrieve all entries from my HANA DB entity with temporal aspect, so also the 'invalid' ones. I was hoping a CQN query like this should work, but only the 'valid' entries are retrieved from the database:
public async getTemporalFactors(id:Array<string>){
const service = await cds.connect.to('CO2SC3Service');
const cqn = {
SELECT: {
from: { ref: ['TransportFactors'] },
'sap-valid-from': [{ val: '1970-01-01' }]
}
};
return await service.run(cqn);
}I tried this because I noticed you can add these parameters for external oData services: August 2022 | cap≽ire (cloud.sap)
Ideally I want to change the req.query parameter in my on Read handler, to add the sap-valmid-from parameter.
Request clarification before answering.
Temporal entities rely on specific columns to calculate the 'valid-at' and 'valid-from' entries (see: https://cap.cloud.sap/docs/guides/temporal-data). This would imply you can create your own standard query to select the desired entries like this:
SELECT.from(TransportFactors).where({ validFrom: { '>=': '1970-01-01' } })
assuming the 'valid-from' temporal column is called validFrom in your entity.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This would only fetch 'valid' entries (so where validFrom <= now and validTo >= now), and filter those where validFrom >= 1/1/1970.
To me it seems that the the annotations on this temporal aspect make sure on DB level that only valid entries are fetched, unless you use this url parameter.
I hope I'm wrong here 🙂
| User | Count |
|---|---|
| 11 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.