|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lapetus_ltd._2009.xml.types.XLptsDBUpInsDelType
com.lapetus_ltd._2009.xml.types.XLptsDBUpInsDelWhereType
com.lapetus_ltd.api.db.xml.types.TLptsDBUpInsDelWhereType
public class TLptsDBUpInsDelWhereType
Class Description : One of the two classes that extend XLptsDBUpInsDelType for UPDATE, DELETE and INSERT commands.
TLptsDBUpInsDelSetType
and TLptsDBUpInsDelWhereType
.
Both of these classes are used in the process of UPDATING, whereas only TLptsDBUpInsDelWhereType
is used for DELETING and
and only TLptsDBUpInsDelSetType
is used for INSERTING data.
So lets go into how it works in more detail. Both these classes are set against a column in a data set or statement.
The column is either used to be updated or as a pointer to which records are to be updated (like for the update or delete).
The column that is to have data inserted or updated against it is the SET column and uses the TLptsDBUpInsDelSetType
in the
XLptsDBStatementColumnType.setUpInsDelParameterItem(com.lapetus_ltd._2009.xml.types.XLptsDBUpInsDelType)
function. The column that specifies
which records (or rows) are to be updated is the WHERE column and needs the TLptsDBUpInsDelWhereType
set in the
XLptsDBStatementColumnType.setUpInsDelParameterItem(com.lapetus_ltd._2009.xml.types.XLptsDBUpInsDelType)
function.
Let us look at a diagrammatic depiction of how to use the two XLptsDBUpInsDelType
class inheritors.
In an UPDATE scenario in the table below we want to update the COLUMN 2 values and use COLUMN 5 to specify which rows to update.
MyTable
TLptsStatement extends XLptsDBStatementType
|
------------------------------------------------------------------------------------
| | | | | |
Column 1 Column 2 Column 3 Column 4 Column 5 Column 6
| |
TLptsDBUpInsDelSetType TLptsDBUpInsDelWhereType
XLptsDBUpInsDelType.getSourceType()
and XLptsDBUpInsDelType.getSourceString()
.
TLptsLogger
.
If no TLptsDBUpInsDelWhereType is specified, then all records are selected for UPDATE or DELETE.
If many columns are selected in the source Statement or Stored procedure, the first one is used for the relative operation.
The sources types are PROGRAMMATIC (from within the code), from another TLptsStatement or from a database STORED PROCEDURE.
In the later two cases we need to specify the name of the statement or stored procedure in XLptsDBUpInsDelType.setSourceString(java.lang.String)
.
And the relative type needs to be set in XLptsDBUpInsDelType.setSourceType(com.lapetus_ltd._2009.xml.types.XLptsDBUpInsDelSourceType)
.
Below is the code for the above diagram:
// we will assume that the two SELECT statements called COLUMN_2_DATA and COLUMN_5_DATA, already exist // lets also assume that they have selected one column each, that has relative data for the UPDATE and WHERE. TLptsStatement updateStatement = new TLptsStatement(connection,XLptsDBTypeOfStatementType.UPDATE); updateStatement.setXResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE); updateStatement.setXResultSetConcurrency(ResultSet.CONCUR_UPDATABLE); XLptsDBStatementTableType table = updateStatement.getTableItemByName("MyTable"); table.setSelected(true); XLptsDBStatementColumnType column2,column5; column2 = updateStatement.getColumnItemByName(table.getTableName(),"COLUMN_2"); if(column2 != null) { TLptsDBUpInsDelSetType setType = new TLptsDBUpInsDelSetType(XLptsDBUpInsDelSourceType.LPTS_STATEMENT,"COLUMN_2_DATA"); column2.setUpInsDelParameterItem(setType); column2.getUpInsDelParameterItem().setCharset("UTF-16LE"); // this is not required in most cases (see TestUPDATE) } column5 = updateStatement.getColumnItemByName(table.getTableName(),"COLUMN_5"); if(column5 != null) { TLptsDBUpInsDelWhereType whereType = new TLptsDBUpInsDelWhereType(XLptsDBUpInsDelSourceType.LPTS_STATEMENT,"COLUMN_5_DATA"); whereType.setOperation(TLptsFactoryStatement.OPERATION_EQUAL); whereType.setAndConnector(true); column5.setUpInsDelParameterItem(whereType); } updateStatement.setTitle("Update Statement"); System.out.println("SQL Statement " + updateStatement.getTitle() + ": " + updateStatement.getSqlStatementFormatted()); TLptsFactoryRowSet.executeDynamicUpdate(updateStatement); Note: Look at the ExampleDataUpdate and TestUPDATE for more details and complete code with comments.
Field Summary |
---|
Fields inherited from class com.lapetus_ltd._2009.xml.types.XLptsDBUpInsDelWhereType |
---|
andConnector, betweenOther, operation |
Fields inherited from class com.lapetus_ltd._2009.xml.types.XLptsDBUpInsDelType |
---|
charset, columnId, columnIndex, columnName, id, sourceString, sourceType, sqlType, tableId, tableName |
Constructor Summary | |
---|---|
TLptsDBUpInsDelWhereType()
This constructor initiates the UpInsDelType. |
|
TLptsDBUpInsDelWhereType(XLptsDBStatementColumnType sct)
This constructor initiate defaults and set Column details from TLptsDBStatementColumnType. |
|
TLptsDBUpInsDelWhereType(XLptsDBUpInsDelSourceType sourceType,
java.lang.String sourceString)
This constructor initiates the UpInsDelType. |
|
TLptsDBUpInsDelWhereType(XLptsDBUpInsDelWhereType uidt)
This constructor copies the UpInsDelType information from an TLptsDBUpInsDelWhereType. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object obj)
Check for equal TLptsDBUpInsDelWhereType objects. |
Methods inherited from class com.lapetus_ltd._2009.xml.types.XLptsDBUpInsDelWhereType |
---|
getBetweenOther, getOperation, isAndConnector, setAndConnector, setBetweenOther, setOperation |
Methods inherited from class com.lapetus_ltd._2009.xml.types.XLptsDBUpInsDelType |
---|
getCharset, getColumnId, getColumnIndex, getColumnName, getId, getSourceString, getSourceType, getSqlType, getTableId, getTableName, setCharset, setColumnId, setColumnIndex, setColumnName, setId, setSourceString, setSourceType, setSqlType, setTableId, setTableName |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TLptsDBUpInsDelWhereType()
This constructor initiates the UpInsDelType.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never.
Notes : Default Constructor set id, type as NONE, operation as EQUAL, set as false, and as false, sqlType and sqlSubstituteType to -11 and other variables are set to empty string.
Example :
TLptsDBUpInsDelWhereType upInsDelType = new TLptsDBUpInsDelWhereType();
public TLptsDBUpInsDelWhereType(XLptsDBStatementColumnType sct)
This constructor initiate defaults and set Column details from TLptsDBStatementColumnType.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never.
Notes : Use this function every time you need to copy or instantiate a type TLptsDBUpInsDelWhereType class with TLptsDBStatementColumnType information.
Example :
public void example(TLptsDBStatementColumnType sct) { TLptsDBUpInsDelWhereType upInsDelType = new TLptsDBUpInsDelWhereType(sct); } }
sct
- the class object to copy.public TLptsDBUpInsDelWhereType(XLptsDBUpInsDelSourceType sourceType, java.lang.String sourceString)
This constructor initiates the UpInsDelType.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never.
Notes : Default Constructor set id, type as NONE, operation as EQUAL, set as false, and as false, sqlType and sqlSubstituteType to -11 and other variables are set to empty string.
Example :
TLptsDBUpInsDelWhereType upInsDelType = new TLptsDBUpInsDelWhereType();
public TLptsDBUpInsDelWhereType(XLptsDBUpInsDelWhereType uidt)
This constructor copies the UpInsDelType information from an TLptsDBUpInsDelWhereType.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never.
Notes : Use this function every time you need to copy or instantiate a type TLptsDBUpInsDelWhereType class.
Example :
public void example(TLptsDBUpInsDelWhereType uidt) { TLptsDBUpInsDelWhereType upInsDelType = new TLptsDBUpInsDelWhereType(uidt); }
uidt
- the class object to copy.Method Detail |
---|
public boolean equals(java.lang.Object obj)
Check for equal TLptsDBUpInsDelWhereType objects.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : n/a
Notes : Use this to compare two TLptsDBUpInsDelWhereType objects by there id's.
Example :
TLptsDBUpInsDelWhereType upInsDelType1 = new TLptsDBUpInsDelWhereType(); TLptsDBUpInsDelWhereType upInsDelType2 = new TLptsDBUpInsDelWhereType(); return upInsDelType1.equals(upInsDelType2);
equals
in class java.lang.Object
obj
- the DB workspace type
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |