Hi Gurbeer,

It will be more than worth your while to get familiar with a tool to help with 
this. Many folks have had success with Corb. 
<http://developer.marklogic.com/code/corb>

If you really want to do it from QC, you'll have to do some work to break the 
job down into smaller pieces to avoid request timeouts.

As you've discovered, to cross the database (and transaction) boundary, you 
also need to do an eval. For example, if you set the Query Console context 
database to where your source documents are, you can retrieve them with 
fn:collection() or other functions, process them as desired, then insert them 
with code something like this (note the quoted XQuery code)

let $doc := <a-document/>
let $uri := "/a/b/c.xml"
let $target-db := "Documents"

let $code := "
declare variable $uri external;
declare variable $doc external;
xdmp:document-insert($uri, $doc)"

return xdmp:eval($code, (xs:QName("uri"),$uri,xs:QName("doc"),$doc),
<options xmlns="xdmp:eval">
    <database>{xdmp:database($target-db)}</database>
</options>
)

Here $doc and $uri and $target-db you'll need to set according to the needs of 
your process.

But do take a look at Corb. It will make your life easier, I promise. :)

-m


On Feb 11, 2013, at 2:30 PM, "Singh, Gurbeer" 
<[email protected]<mailto:[email protected]>> wrote:


We need to write a JOB which will run over night and  fetch close to 1000 XML 
from one source and move it to another data base

I was planning to write one XQY for this and scheduled it daily.

XQY will run in Source DB and move to destination data-base .

~Gurbeer
From: 
[email protected]<mailto:[email protected]>
 
[mailto:[email protected]<mailto:[email protected]>]
 On Behalf Of David Lee
Sent: Monday, February 11, 2013 5:22 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to move content from one data base 
toanother

How many documents are you dealing with ?
That would give us a better idea of what technique to suggest.
If it's just a few hundred or less than a quick script in QC is easy, and 
Nelson's suggestion should work fine.

If its thousands millions or more than something more powerful is called for.

Also is this a repetitive task or one-off ?



-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
[email protected]<mailto:[email protected]>
Phone: +1 812-482-5224
Cell:  +1 812-630-7622
www.marklogic.com<http://www.marklogic.com/>

From: 
[email protected]<mailto:[email protected]>
 [mailto:[email protected]] On Behalf Of Nelson Wells
Sent: Monday, February 11, 2013 5:13 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to move content from one data base 
toanother

Hi Gurbeer,

If you really want to do these operations through the query console, you can 
use xdmp:eval (http://docs.marklogic.com/xdmp:eval) to specify a database other 
than your context DB.  I think Geert’s suggestions are going to be more robust 
and scalable, though.

Nelson Wells

From: 
[email protected]<mailto:[email protected]>
 [mailto:[email protected]] On Behalf Of Singh, Gurbeer
Sent: Monday, February 11, 2013 4:05 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to move content from one data base 
toanother

I didn’t get it,

I am In CQ  (Source database), I got the URI which I need to move , I created a 
variable

Let $doc:= fn:doc($uri)

Now I need to save this $doc to destination data base , how I can connect to 
destination data-base when I am in source data-base.

One way looks to me, write some .net/Java code call XQRY to source data-base, 
get the result and dump it to destination data-base


I tried something like this
xdmp:document-insert(
   $newuri,
   $doc,
   xdmp:default-permissions(),
   xdmp:default-collections(),
   0,
   11130048076528179319
)

Getting error
Specified forest 11130048076528179319 not in database

Which is true. Any other suggestion.

~Gurbeer

From: 
[email protected]<mailto:[email protected]>
 [mailto:[email protected]] On Behalf Of Tim Meagher
Sent: Monday, February 11, 2013 4:33 PM
To: 'MarkLogic Developer Discussion'
Subject: Re: [MarkLogic Dev General] How to move content from one data base 
toanother

What I did was to create a xdmp:get utility that 1st acquires the list of URIs 
that I want to extract from the source database - note that I have custom code 
on the source server which reads request fields to determine exactly what 
content to return.  Next I iteratively spawn a utility that invokes a transform 
on the source server and returns the resulting document that I then insert 
using xdmp:document-insert to the local database.

Tim

________________________________
From: 
[email protected]<mailto:[email protected]>
 [mailto:[email protected]] On Behalf Of Singh, Gurbeer
Sent: Monday, February 11, 2013 2:18 PM
To: [email protected]<mailto:[email protected]>
Subject: [MarkLogic Dev General] How to move content from one data base 
toanother

Hi,

We have created two Database under a ML  instance.

Now we have to move some content from one data base to another , before moving 
we need to do apply some logic.

I was wondering how can use    xdmp:document-insert for this approach.



~Gurbeer

________________________________

NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or 
views contained herein are not intended to be, and do not constitute, advice 
within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and 
Consumer Protection Act. If you have received this communication in error, 
please destroy all electronic and paper copies and notify the sender 
immediately. Mistransmission is not intended to waive confidentiality or 
privilege. Morgan Stanley reserves the right, to the extent permitted under 
applicable law, to monitor electronic communications. This message is subject 
to terms available at the following link: 
http://www.morganstanley.com/disclaimers If you cannot access these links, 
please notify us by reply message and we will send the contents to you. By 
messaging with Morgan Stanley you consent to the foregoing.

________________________________

NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or 
views contained herein are not intended to be, and do not constitute, advice 
within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and 
Consumer Protection Act. If you have received this communication in error, 
please destroy all electronic and paper copies and notify the sender 
immediately. Mistransmission is not intended to waive confidentiality or 
privilege. Morgan Stanley reserves the right, to the extent permitted under 
applicable law, to monitor electronic communications. This message is subject 
to terms available at the following link: 
http://www.morganstanley.com/disclaimers If you cannot access these links, 
please notify us by reply message and we will send the contents to you. By 
messaging with Morgan Stanley you consent to the foregoing.


NOTICE OF CONFIDENTIALITY: This electronic message, including attachments, is 
for the sole use of the named recipient and may contain confidential or 
privileged information protected by State of Tennessee and Federal regulations. 
Any unauthorized review, use, disclosure, copying or distribution is strictly 
prohibited. If you are not the intended recipient or have received this 
communication in error please contact the sender or 
[email protected]<mailto:[email protected]> and destroy all 
copies of the original message. Thank you.


________________________________

NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or 
views contained herein are not intended to be, and do not constitute, advice 
within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and 
Consumer Protection Act. If you have received this communication in error, 
please destroy all electronic and paper copies and notify the sender 
immediately. Mistransmission is not intended to waive confidentiality or 
privilege. Morgan Stanley reserves the right, to the extent permitted under 
applicable law, to monitor electronic communications. This message is subject 
to terms available at the following 
link:http://www.morganstanley.com/disclaimers If you cannot access these links, 
please notify us by reply message and we will send the contents to you. By 
messaging with Morgan Stanley you consent to the foregoing.



_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to