|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcds.sql.SQLInsert
SQL 'INSERT' statement building class.
It receives a table name, and pairs of colums (optional) and values
(mandatory).
It is possible to add colums and values in an asynchronous way, as long
as the order and number of items remains synchronized. Colums names can
be combined in one call: addColumn("col1,col2,col3") for instance.
When finished, the toString() method returns the full
INSERT statement.
Field Summary | |
private java.lang.StringBuffer |
colNames
|
private java.lang.String |
tableName
|
private java.lang.StringBuffer |
values
|
Constructor Summary | |
SQLInsert()
Constructor of an INSERT statement with column names and values |
|
SQLInsert(boolean withNames)
Constructor of an INSERT statement. the parameter determines if column names will be present. |
Method Summary | |
void |
addColumn(java.lang.String col)
Adds a column name into the INSERT command |
void |
addItem(java.lang.String col,
java.lang.String val)
Adds an item pair (column name and value) into the INSERT command. |
void |
addNull()
Sets a null value without a column name into the INSERT command. |
void |
addNull(java.lang.String col)
Sets a null value with its column name into the INSERT command. |
void |
addQuotedItem(java.lang.String col,
java.lang.String val)
Adds an item pair (column name and value) into the INSERT command. |
void |
addQuotedValue(java.lang.String val)
Sets a quoted value into the INSERT command. |
void |
addValue(java.lang.String val)
Sets an item value into the INSERT command. |
void |
reset()
Resets a SQLInsert object (avoiding a object creation) |
void |
setTable(java.lang.String table)
Sets the table name. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private java.lang.String tableName
private java.lang.StringBuffer colNames
private java.lang.StringBuffer values
Constructor Detail |
public SQLInsert()
public SQLInsert(boolean withNames)
withNames
- true if column names may exist. Even if this parameter
is set to true, it is still possible to write only values. But a
mixture of calls with and without column names is of course forbiddenMethod Detail |
public void setTable(java.lang.String table)
table
- table name for the INSERT commandpublic void addItem(java.lang.String col, java.lang.String val)
col
- column nameval
- value. This value will not be enclosed in quotes.public void addQuotedItem(java.lang.String col, java.lang.String val)
col
- column nameval
- value. This value will be enclosed in quotes.public void addColumn(java.lang.String col)
col
- column namepublic void addValue(java.lang.String val)
val
- value. This value will not be enclosed in quotes.public void addQuotedValue(java.lang.String val)
val
- value. This value will be enclosed in quotes.public void addNull(java.lang.String col)
col
- column namepublic void addNull()
public void reset()
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |