cancel
Showing results for 
Search instead for 
Did you mean: 

CQL UPDATE entity with case when statement on timestamp

09-27-2022 9:14 AM
sdeissenboeck Product and Topic Expert
555 views 0 comments
0 Likes
SAP Managed Tags
Subscribe

I am trying to UPDATE an entity set with a where condition containing the comparison of two timestamps. However, this is not working, as somehow the timestamps can't be compared (I don't get any hits).

UPDATE(CardReceiverAllocation)
.set({ isCurrentAllocation: true })
.where({ card_ID: receiverEntryResult.card_ID, receiver_ID: receiverEntryResult.receiver_ID,
timestamp: maxTimestamp })

As an alternative I tried to write the UPDATE statement with an inclusive CASE WHEN statement, but this is generating the error "column is of type boolean but expression is of type text".

Does anybody know of a solution on how to achieve this update? Thank you in advance!

UPDATE`efa_CardReceiverAllocation`.
set`isCurrentAllocation = (case when timestamp = (select max(timestamp)
as maxTimestamp from efa.CardReceiverAllocation as CRA
where CRA.receiver_ID = receiver_ID and CRA.card_ID = card_ID ) then true else false end)`
0 Likes

Accepted Solutions (0)

Answers (0)