<?php require_once( dirname(dirname(dirname( __FILE__ ))) . '/wp-load.php' ); ?>
<!-- START of header -->
<?php get_header(); ?>
<!-- END of header -->

<!-- warapper -->

<div class="docs-content">
    <!-- START of page navigation -->
    <?php get_template_part( 'docs_navigation' ); ?>
    <!-- END of page navigation -->
    <!-- START of pusher -->
    <div class="docs-content-body">
        <div id="content" class="docs-content-body__inner">
            <h1>5.1.10 Data Deletion</h1>
            <h1 class="title"></h1>
            <h2 id="overview">Overview</h2>
            <p>This chapter covers deleting data from a GridDB collection.</p>
            <p><br/></p>
            <h2 id="data-deletion">Delete data</h2>
            <p>Delete data from a collection with specifying a Row key.</p>
            <strong> List.1 Delete Data</strong> (CollectionDeleteRow.java)
            <pre class="prettyprint linenums:23">
            // Get Collection
            Collection weatherStationCol =
                    store.getCollection("weather_station", WeatherStation.class);

            // Delete Row
            boolean deleteSucceed = weatherStationCol.remove("1");
            System.out.println("Delete Succeed:" + deleteSucceed);

            System.out.println("ID\tName\t\t\tLongitude\tLatitude\tCamera");
            for (int i = 0; i &lt; WeatherStationLogic.JP_PREFECTURE; i++) {
                // Retrieve row by key
                WeatherStation weatherStation = weatherStationCol.get(String.valueOf(i + 1));
                if (weatherStation != null) {
                    System.out.println(String.format(&quot;%-3s\t%-20s\t%-10s\t%-10s\t%-5s&quot;,
                            weatherStation.id, weatherStation.name, weatherStation.latitude,
                            weatherStation.longitude, weatherStation.hasCamera));
                } else {
                    System.out.println(String.format(&quot;ID:%s is not exist&quot;, (i + 1)));
                }
            }
            </pre>
            <ul>
            <li>L.28: Delete a Row with specifying the measuring instrument ID using <code>Container.remove(String)</code> method. If the deletion was sucesseful, the return value is True.</li>
            <li>L.32-42: Display the retrieved data after the deletion.</li>
            </ul>
            <p><br>Execution results are as follows:</p>
            <strong> List.2 Result</strong>
<pre class="prettyprint">
Delete Succeed:true
ID  Name        Longitude   Latitude    Camera
ID: 1 does not exist
2   Aomori-Aomori   40.82444    140.74      false
3   Iwate-Morioka   39.70361    141.1525    true
4   Miyagi-Sendai   38.26889    140.87194   false
5   Akita-Akita 39.71861    140.1025    true
(Snip)
</pre>
            <p><br/></p>
            <h2 id="complete-source-code">Complete Source Code</h2>
            <p>Complete source code used in this sample can be downloaded from the following.</p>
            <p>Download: <a href="img/collection-delete.zip">griddb-delete.zip</a></p>

            </div>
        </div>
    </div>
</div>
</div>

<!-- / main -->

<?php get_footer(); ?>
