Hi,
I am trying to do insert-select in N1QL. It is part of longer process…
I am trying to copy all docs of one type and modify them. I was thinking about saving them with a different key (and if possible type).
That example copies all values from one bucket to the other. How can I take just some cols? Can I also change the key of docs?
I was trying something like this:
INSERT INTO carly_test (key docId, value _v)
select site, max(docId) dealDocId, ‘uDeal’ docType, ‘uDeal::’ || site docId
from carly_test as _v
where docType like 'dealer%'
group by site
In insert-select example in your documentation it is confusing to me that you named have 3 things named _v: bucket alias, value parameter and ?. Is the 3rd thing (second col in select statement) a reference to all cols in bucket? Or some special function?
INSERT INTO bucket1 (key _k, value _v) SELECT META().ID _k, _v FROM bucket2 _v;
@ingenthr@prasad
is there any way to do insert and select if i have to do projectection of all the document of a particular type
SELECT META().id ||“_PT” _k,{s.*,“type” : “PT”} _v from system:completed_requests s limit 10
gives below error
[
{
“code”: 3000,
“msg”: “syntax error - at ",
“query_from_user”: "SELECT META().id ||"_PT" _k,{s.,"type" : "PT"} _v from system:completed_requests s limit 10”
}
]