# How to read data from db subsequently (incremental reading)?

**URL:** <https://forum.cloverdx.com/t/how-to-read-data-from-db-subsequently-incremental-reading/424>\
**Category:** CloverDX Platform\
**Created:** [October 23, 2008, 12:00am UTC](https://forum.cloverdx.com/t/how-to-read-data-from-db-subsequently-incremental-reading/424 "2008-10-23T00:00:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![avackova](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@avackova](https://forum.cloverdx.com/u/avackova)\
**Post date:** [October 23, 2008, 12:00am UTC](https://forum.cloverdx.com/t/how-to-read-data-from-db-subsequently-incremental-reading/424/1 "2008-10-23T00:00:00Z")

</div>

It is possible to create graph, that reads only “new” (added from the last run of graph) data from database.  
Look at following DBInputTable definition:

```auto
<Node dbConnection="Connection0" id="INPUT" incrementalFile="dbInc.txt" incrementalKey="key=max(employee_id)" sqlQuery="select * from employee where employee_id>#key" type="DB_INPUT_TABLE"/>

```

In the above node, new records are defined by clause _where employee\_id\>#key_ and _key_ is stored as maximum value from the last database reading. You have also to define the file, that stores the incremental key value. For the first reading you must define the key by hand (create file, where are keys and theirs values eg.

```auto
key = -1

```

).

The incremental key can consist of more then one field (_sqlQuery=“select \* from employee where hire\_date \> #key1 or employee\_id \> #key2”_, _incrementalKey=“key1=first(hire\_date);key2=max(employee\_id)”_) and available value in key definition are: _first,last,max_ and _min_.
