Book Image

JDBC 4.0 and Oracle JDeveloper for J2EE Development

Book Image

JDBC 4.0 and Oracle JDeveloper for J2EE Development

Overview of this book

Table of Contents (20 chapters)
JDBC 4.0 and Oracle JDeveloper for J2EE Development
Credits
About the Author
About the Reviewer
Preface

Deleting a Row in a Database


We will delete a database table row using the XML SQL Utility. A database table row can be deleted by specifying element tags corresponding to key columns in an XML document. An example XML document, catalog-delete.xml, specifies the catalogId, "catalog2". We will delete from the table JOURNAL the row for which the primary key column, CATALOGID, that has the value "catalog2" as specified in catalog-delete.xml is listed below:

<?xml version="1.0" encoding="utf-8"?>
<catalog>
<journal>
<catalogId>catalog2</catalogId>
</journal>
</catalog>

We have to create an OracleXMLSave object, setting the row enclosing tag and setting ignore case to true, as discussed in the previous section.

OracleXMLSave oracleXMLSave =new OracleXMLSave(conn, "JOURNAL");
oracleXMLSave.setRowTag("journal");
oracleXMLSave.setIgnoreCase(true);

Set key columns using the setKeyColumnList(String[] keyColumns) method and set CATALOGID as a key column.

String...