Fetching the records from schema based on size | Community
Skip to main content
Level 2
August 3, 2018
Question

Fetching the records from schema based on size

  • August 3, 2018
  • 3 replies
  • 2216 views

Hi Team,

I want to retrieve the records based on size from schema in adobe campaign...so how to implement this one in Adobe campaign.

For Example:

if schema having 100 records then i need to select 20 records only from 100 recors

And next time i need to  retrive from 20 to 40 records and next ineed to retrive the records from 40 to so...

So how to achieve this ...please help me on this..

Regards

Jitendra

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

vraghav
Adobe Employee
Adobe Employee
August 4, 2018

Hi Jitendra,

You can try this code in a JS activity

var recordsToFetchPerBatch = 20; 

var currentStartLine = 0;

var query = xtk.queryDef.create(

  <queryDef schema="cus:mySchema" operation="select" lineCount={recordsToFetchPerBatch} startLine={currentStartLine}>

    <select>

      <node expr="@id"/>   

    </select>

  </queryDef>);

var result = query.ExecuteQuery();

try

{

while (result != "")

 

for each (var record in result)

{

currentStartLine++;

           

//do your stuff

     

} // end for

query = xtk.queryDef.create(

<queryDef schema="cus:mySchema" operation="select" lineCount={recordsToFetchPerBatch} startLine={currentStartLine}>

<select>

  <node expr="@id"/>   

</select>

  </queryDef>);

var result = query.ExecuteQuery();

} // end while

}

catch (e)

{

  logError("*** FAILED ***");

}

Regards,
Vipul

Level 2
August 6, 2018

Hi Vipul,

Thank you for your response,I am not able to fetch the any records from schema by using below  code.Please help me on this if anything i am doing wrong.

Schema Data:

vraghav
Adobe Employee
Adobe Employee
August 7, 2018

Hi jitendrat76652144,

There is a second queryDef in this code which you have completely skipped

Without this, your while loop code will run into an infinite loop.

Regards,
Vipul