Hi, I have a doubt about merge statement, I need update the record when EXISTS and its status is NOT resolved and LastUpdate < newRecord.lastUpdate , and INSERT when NOT EXISTS.
the query is like this:
merge into mybucket
using (select id from mybucket where lastUpdate < newRecord.lastUpdate and status != “RESOLVED”)
when matched then UPDATE SET…
I think that to INSERT it should comply whitn the ONLY condition IS NOT EXIST.
Hello, I have this query but it never insert the document.
when matched the document is updated correctly , but when not matched never inserts the document.
Where is the problem?
MERGE INTO mybucket b
USING (select meta().id from APP_mybucket_DATA use keys ‘key’ ) as xxx ON KEY xxx.id
WHEN MATCHED THEN
update set b.name = 'C3CC’
WHEN NOT MATCHED THEN
insert {“documentType”:“cccc”,“bases”:[],“createTime”:…}
All SDKs have an option for executing an arbitrary String, so it’s always possible to execute any statement that can be assembled by String alone. Some SDKs have additional platform specific APIs (e.g. the DSL in Java or LINQ in .NET), but we ensure that the String option is always there.
The developer documentation has a section on N1QL from the SDK. Select the platform of interest from the pulldown in the upper right navigation.