Hi everybody,
I use your HXTT-DBF-Driver. Sometimes I add a new column to an existing table. Is it possible to fill this column with default values? (boolean=false, integer=0, double=0.0, and so on)
It's the same problem, if I make a database-insert and don't fill every column(look at my example below)
In your documentation http://www.hxtt.com/dbf/sqlsyntax.html#createtable I found this:
-------------------
The HXTT DBF will ignore DEFAULT expression
-------------------
I suspect, that's why it doesn't work yet?
Here is my example
-------------------------------------------
package mainKlassen;
import java.sql.*;
public class MinimalClass {
public static void main(String[] args) {
String sTableName = "tab";
String connectionUrl;
Connection con;
Statement stmt;
String sSQL;
connectionUrl = "jdbc:dbf:/c:/dbf?versionNumber=03";
try {
Class.forName("com.hxtt.sql.dbf.DBFDriver");
con = DriverManager.getConnection(connectionUrl);
stmt = con.createStatement();
sSQL = "DROP TABLE IF EXISTS " + sTableName;
stmt.executeUpdate(sSQL);
sSQL = "CREATE TABLE " + sTableName + " (int1 NUMERIC(5), int2 NUMERIC(5))";
stmt.executeUpdate(sSQL);
sSQL = "INSERT INTO " + sTableName + " (int1) values (2)";
stmt.executeUpdate(sSQL);
sSQL = "ALTER TABLE " + sTableName + " add int3 NUMERIC(5) DEFAULT 3";
stmt.executeUpdate(sSQL);
stmt.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
------------------------------------
Greetings from Germany
|
>I suspect, that's why it doesn't work yet?
Because Xbase compatible format will use null/empty value as default value.
|