DBOUpdate
Description
The DBOUpdate element represents the DBO optimized for update operations.
GreenVulcano® ESB configuration
DBOUpdate allows you to update data into the database.
Each statement is identified by the id.
Actions can be defined in two ways:
- Single execution of a statement
- Complex execution guided by XML
In the first modality any input is ignored and the code executes the first statement configured.
In the second mode, the input XML (or its transformation) must contain the command (row) valid with all parameters (COL) required by the statement.
It is used by DBOBuilder.
The following table shows the DBOUpdate attributes:
Attribute | Type | Description |
---|---|---|
type | fixed | This attribute must assume the value dbo |
class | fixed | This attribute must assume the value it.greenvulcano.gvesb.datahandling.dbo.DBOUpdate |
name | required | DBOUpdate name |
transformation | required | Transformation to be applied on the input data to obtain the internal XML commands. |
force-mode | optional | (caller or xml2db) Force mode of the DBO, can be used in DBOBuilder whit more heterogeneous DBOs. Mode: caller - inherit the mode of the caller xml2db - data entry mode |
jdbc-connection-name | optional | DataSource JNDI name. Override connection defined in DBOBuilder. |
ignore-input | optional | (true or false) Tells the engine do not use the input data. |
input-data | optional | The default is the value of @name-Input. Can be set as the @output-data of a preceding DBO to use its output as input. |
output-data | optional | The default is the value of @name-Output. |
Attribute | Type | Description |
---|---|---|
autogenerate-keys | optional | Tell the engine to handle auto generated keys at runtime (ex. autoincrement primary key fields). Default to false. |
It's possible to use positional parameters ? notation or named parameters :name notation into statement definition, but not mixed in the same statement.
For example, given the following table:
CREATE TABLE "TEST_GV"."CREDIT_CARD" (
"ID" NUMBER NOT NULL,
"ID_OWNER" NUMBER NOT NULL,
"CNUMBER" VARCHAR2(20 CHAR) NOT NULL,
"CREDIT" NUMBER(15,5) NOT NULL,
"ENABLED" VARCHAR2(1 CHAR) NOT NULL,
CONSTRAINT "CCRED_PK" PRIMARY KEY ("ID")
)
the following input XML:
<ser:Pay xmlns:ser="http://www.credit.com/services">
<ser:cnumber>1111222233334444</ser:cnumber>
<ser:amount>10</ser:amount>
</ser:Pay>
the following DBOUpdate can update the table:
<DBOBuilder class="it.greenvulcano.gvesb.datahandling.dbobuilder.DBOBuilder"
jdbc-connection-name="gv_test" name="CCardPay" type="dbobuilder">
<DHVariables>
<DHVariable name="decimal-separator" value="."/>
<DHVariable name="grouping-separator" value=","/>
<DHVariable name="format" value="#0.00"/>
</DHVariables>
<DBOUpdate class="it.greenvulcano.gvesb.datahandling.dbo.DBOUpdate"
name="CCardPay" transformation="CCardPay" type="dbo">
<statement id="1" type="update"><![CDATA[update CREDIT_CARD set CREDIT= CREDIT - ?
where CNUMBER=?
and ENABLED='Y'
and CREDIT >= ?]]></statement>
</DBOUpdate>
</DBOBuilder>
through the following XSL transformation:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl int fs" version="2.0"
xmlns:fs="http://www.w3.org/2005/xpath-functions"
xmlns:int="http://www.credit.com/services"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output encoding="utf-8" indent="yes" method="xml"/>
<xsl:template match="/">
<xsl:element name="RowSet">
<xsl:apply-templates select="/int:Pay"/>
</xsl:element>
</xsl:template>
<xsl:template match="/int:Pay">
<xsl:element name="data">
<xsl:element name="row">
<xsl:attribute name="id">1</xsl:attribute>
<xsl:element name="col">
<xsl:attribute name="type">float</xsl:attribute>
<xsl:value-of select="int:amount"/>
</xsl:element>
<xsl:element name="col">
<xsl:value-of select="int:cnumber"/>
</xsl:element>
<xsl:element name="col">
<xsl:attribute name="type">float</xsl:attribute>
<xsl:value-of select="int:amount"/>
</xsl:element>
<xsl:element name="col-update"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Using named parameters, the following DBOUpdate can update the table:
<DBOBuilder class="it.greenvulcano.gvesb.datahandling.dbobuilder.DBOBuilder"
jdbc-connection-name="gv_test" name="CCardPay" type="dbobuilder">
<DHVariables>
<DHVariable name="decimal-separator" value="."/>
<DHVariable name="grouping-separator" value=","/>
<DHVariable name="format" value="#0.00"/>
</DHVariables>
<DBOUpdate class="it.greenvulcano.gvesb.datahandling.dbo.DBOUpdate"
name="CCardPay" transformation="CCardPay" type="dbo">
<statement id="1" type="update"><![CDATA[update CREDIT_CARD set CREDIT= CREDIT - :amount
where CNUMBER=:cnumber
and ENABLED='Y'
and CREDIT >= :amount]]></statement>
</DBOUpdate>
</DBOBuilder>
through the following XSL transformation:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl fs" version="2.0"
xmlns:fs="http://www.w3.org/2005/xpath-functions"
xmlns:int="http://www.credit.com/services"
xmlns:ns0="http://www.greenvulcano.com/database"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsl:output encoding="utf-8" indent="yes" method="xml"/>
<xsl:template match="/">
<xsl:element name="RowSet" namespace="http://www.greenvulcano.com/database">
<xsl:element name="data" namespace="http://www.greenvulcano.com/database">
<xsl:apply-templates select="/int:Pay"/>
</xsl:element>
</xsl:element>
</xsl:template>
<xsl:template match="/int:Pay">
<xsl:element name="row" namespace="http://www.greenvulcano.com/database">
<xsl:attribute name="id">1</xsl:attribute>
<xsl:element name="cnumber" namespace="http://www.greenvulcano.com/database">
<xsl:attribute name="type">float</xsl:attribute>
<xsl:value-of select="int:cnumber"/>
</xsl:element>
<xsl:element name="amount" namespace="http://www.greenvulcano.com/database">
<xsl:attribute name="type">float</xsl:attribute>
<xsl:value-of select="int:amount"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
DBOUpdate might contain the following sub-elements: