|
|||||||||
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.XLptsDBUpInsDelSetType
com.lapetus_ltd.api.db.xml.types.TLptsDBUpInsDelSetType
public class TLptsDBUpInsDelSetType
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.XLptsDBUpInsDelType |
---|
charset, columnId, columnIndex, columnName, id, sourceString, sourceType, sqlType, tableId, tableName |
Constructor Summary | |
---|---|
TLptsDBUpInsDelSetType()
This constructor initiates the UpInsDelType. |
|
TLptsDBUpInsDelSetType(XLptsDBStatementColumnType sct)
This constructor initiate defaults and set Column details from TLptsDBStatementColumnType. |
|
TLptsDBUpInsDelSetType(XLptsDBUpInsDelSetType uidt)
This constructor copies the UpInsDelType information from another TLptsDBUpInsDelSetType. |
|
TLptsDBUpInsDelSetType(XLptsDBUpInsDelSourceType sourceType,
java.lang.String sourceString)
This constructor initiates the UpInsDelType. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object obj)
Check for equal TLptsDBUpInsDelSetType objects. |
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 TLptsDBUpInsDelSetType()
This constructor initiates the UpInsDelType.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never.
Notes :
Example :
TLptsDBUpInsDelSetType upInsDelType = new TLptsDBUpInsDelSetType();
public TLptsDBUpInsDelSetType(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 TLptsDBUpInsDelSetType class with TLptsDBStatementColumnType information.
This is normally done internally so that the information from the column can be duplicated inside this class for
efficient execution of the application.
Example :
public void example(TLptsDBStatementColumnType sct) { TLptsDBUpInsDelSetType upInsDelType = new TLptsDBUpInsDelSetType(sct); } }
sct
- the class object to copy.public TLptsDBUpInsDelSetType(XLptsDBUpInsDelSetType uidt)
This constructor copies the UpInsDelType information from another TLptsDBUpInsDelSetType.
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 TLptsDBUpInsDelSetType class.
Example :
public void example(XLptsDBUpInsDelSetType uidt) { TLptsDBUpInsDelSetType upInsDelType = new TLptsDBUpInsDelSetType(uidt); }
uidt
- the class object to copy.public TLptsDBUpInsDelSetType(XLptsDBUpInsDelSourceType sourceType, java.lang.String sourceString)
This constructor initiates the UpInsDelType.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : Never.
Notes :
Example :
TLptsDBUpInsDelSetType upInsDelType = new TLptsDBUpInsDelSetType(XLptsDBUpInsDelSourceType.PROGRAMMATIC,"SelectForColumn1");
sourceType
- The type of source, which is either XLptsDBUpInsDelSourceType.PROGRAMMATIC, LPTS_STATEMENT,STORED_PROCEDURE or NONE;sourceString
- The static value if it is PROGRAMMATIC, the name of a statement or the name of a stored procedure.Method Detail |
---|
public boolean equals(java.lang.Object obj)
Check for equal TLptsDBUpInsDelSetType objects.
Thread Safe : Yes
Spawns its own Thread : No
May Return NULL : n/a
Notes : Use this to compare two TLptsDBUpInsDelSetType objects by their id's.
Example :
TLptsDBUpInsDelSetType upInsDelType1 = new TLptsDBUpInsDelSetType(); TLptsDBUpInsDelSetType upInsDelType2 = new TLptsDBUpInsDelSetType(); return upInsDelType1.equals(upInsDelType2); RESULT IS ALWAYS FALSE - as the instantiations always generate a new ID.
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 |