Board index » jbuilder » NEWBIE :: QueryDataSet : saveChanges throws exception for deleted rows

NEWBIE :: QueryDataSet : saveChanges throws exception for deleted rows


2004-03-07 01:45:45 AM
jbuilder4
Hello,
I try to make a sample program using QueryDataSet.
In this program, I want to delete a specific row using the primary index.
Everything is OK, except when i want to use QueryDataSet.saveChanges()
method. I get an exception and the row is not deleted.
Here an extract of my program :
==============================================================
Database m_oPISDatabase = null;
QueryDataSet m_oQueryDataSetPIS = null;
Column m_oPisIdColumn = null;
DataSet oPISDetail;
DataRow oRowSearch;
int nID = 30;
int lRowID, nDeleted ;
m_oQueryDataSetPIS = new QueryDataSet();
m_oPISDatabase = new Database();
m_oPisIdColumn = new Column();
m_oPISDatabase.setConnection(new
com.borland.dx.sql.dataset.ConnectionDescriptor
("jdbc:mysql://xxx.xxx.xxx.xxx/WSPIS", "guest", "guest", false,
"com.mysql.jdbc.Driver"));
m_oPISDatabase.setDatabaseName("");
m_oQueryDataSetPIS.setMetaDataUpdate(MetaDataUpdate.NONE);
m_oQueryDataSetPIS.setTableName("PIS");
m_oQueryDataSetPIS.setQuery(new
com.borland.dx.sql.dataset.QueryDescriptor(
m_oPISDatabase, "SELECT PIS_ID FROM PIS", null, true, Load.ALL));
m_oQueryDataSetPIS.setEditable(true);
m_oQueryDataSetPIS.setDisplayErrors(true);
m_oQueryDataSetPIS.setAccumulateResults(true);
m_oQueryDataSetPIS.setEnableDelete(true);
m_oQueryDataSetPIS.setEnableUpdate(true);
m_oQueryDataSetPIS.setReadOnly(false);
m_oQueryDataSetPIS.setResolvable(true);
m_oQueryDataSetPIS.setStoreName("PIS");
m_oQueryDataSetPIS.setTableName("PIS");
m_oPisIdColumn.setCaption("ID");
m_oPisIdColumn.setTableName("PIS");
m_oPisIdColumn.setColumnName("PIS_ID");
m_oPisIdColumn.setRowId(true);
m_oPisIdColumn.setServerColumnName("PIS_ID");
m_oPisIdColumn.setDataType(com.borland.dx.dataset.Variant.INT);
m_oPisIdColumn.setSqlType(java.sql.Types.INTEGER);
m_oQueryDataSetPIS.setColumns(new Column[] {m_oPisIdColumn, });
m_oResover.setDatabase(m_oPISDatabase);
m_oQueryDataSetPIS.setResolvable(true);
m_oQueryDataSetPIS.setRowId("PIS_ID",true);
m_oQueryDataSetPIS.open();
oPISDetail = m_oQueryDataSetPIS.getStorageDataSet();
oRowSearch = new DataRow(oPISDetail, "PIS_ID");
oRowSearch.setInt("PIS_ID",nID);
if( m_oQueryDataSetPIS.locate(oRowSearch, Locate.FIRST) )
{
lRowID = m_oQueryDataSetPIS.getInt("PIS_ID"); //I GET HERE lRowID =
30
m_oQueryDataSetPIS.deleteRow();
nDeleted = m_oQueryDataSetPIS.getDeletedRowCount(); // I GET HERE
nDeleted = 1
m_oPISDatabase.saveChanges(m_oQueryDataSetPIS); //HERE IS WHEN THE
EXCEPTION COMES
}
=====================================================================
The exception I have is :
com.borland.dx.dataset.DataSetException : BASE+51
Can someone help me...
Thanks in advance.
Paul
 
 

Re:NEWBIE :: QueryDataSet : saveChanges throws exception for deleted rows

I have got a little precision.
The code extrated is not exactly the code that have the exception.
After several test, I found the problem.
The query was in the original code :
"SELECT PIS_ID, PIS_CREATION_DATE FROM PIS"
The PIS_CREATION_DATE design was : null value not allowed, default value =
0000-00-00
When the field to delete contained PIS_CREATION_DATE = '0000-00-00', the
exception is raised when i delete the field
When the field to delete contained PIS_CREATION_DATE = '2003-02-23', the row
is correctly deleted.
Could, someone explain to me the reason about this special behaviour ? Why
the exception don't inform me the problem was on this field ?
Thanks.
Paul
"Paul D." < XXXX@XXXXX.COM >a écrit dans le message de news:
404a0e0c$ XXXX@XXXXX.COM ...
Quote
Hello,

I try to make a sample program using QueryDataSet.

In this program, I want to delete a specific row using the primary index.
Everything is OK, except when i want to use QueryDataSet.saveChanges()
method. I get an exception and the row is not deleted.

Here an extract of my program :

==============================================================
Database m_oPISDatabase = null;
QueryDataSet m_oQueryDataSetPIS = null;
Column m_oPisIdColumn = null;
DataSet oPISDetail;
DataRow oRowSearch;
int nID = 30;
int lRowID, nDeleted ;


m_oQueryDataSetPIS = new QueryDataSet();
m_oPISDatabase = new Database();
m_oPisIdColumn = new Column();

m_oPISDatabase.setConnection(new
com.borland.dx.sql.dataset.ConnectionDescriptor
("jdbc:mysql://xxx.xxx.xxx.xxx/WSPIS", "guest", "guest",
false,
"com.mysql.jdbc.Driver"));
m_oPISDatabase.setDatabaseName("");

m_oQueryDataSetPIS.setMetaDataUpdate(MetaDataUpdate.NONE);
m_oQueryDataSetPIS.setTableName("PIS");

m_oQueryDataSetPIS.setQuery(new
com.borland.dx.sql.dataset.QueryDescriptor(
m_oPISDatabase, "SELECT PIS_ID FROM PIS", null, true, Load.ALL));
m_oQueryDataSetPIS.setEditable(true);
m_oQueryDataSetPIS.setDisplayErrors(true);
m_oQueryDataSetPIS.setAccumulateResults(true);
m_oQueryDataSetPIS.setEnableDelete(true);
m_oQueryDataSetPIS.setEnableUpdate(true);
m_oQueryDataSetPIS.setReadOnly(false);
m_oQueryDataSetPIS.setResolvable(true);
m_oQueryDataSetPIS.setStoreName("PIS");
m_oQueryDataSetPIS.setTableName("PIS");
m_oPisIdColumn.setCaption("ID");
m_oPisIdColumn.setTableName("PIS");
m_oPisIdColumn.setColumnName("PIS_ID");
m_oPisIdColumn.setRowId(true);
m_oPisIdColumn.setServerColumnName("PIS_ID");
m_oPisIdColumn.setDataType(com.borland.dx.dataset.Variant.INT);
m_oPisIdColumn.setSqlType(java.sql.Types.INTEGER);

m_oQueryDataSetPIS.setColumns(new Column[] {m_oPisIdColumn, });
m_oResover.setDatabase(m_oPISDatabase);
m_oQueryDataSetPIS.setResolvable(true);
m_oQueryDataSetPIS.setRowId("PIS_ID",true);
m_oQueryDataSetPIS.open();

oPISDetail = m_oQueryDataSetPIS.getStorageDataSet();
oRowSearch = new DataRow(oPISDetail, "PIS_ID");
oRowSearch.setInt("PIS_ID",nID);
if( m_oQueryDataSetPIS.locate(oRowSearch, Locate.FIRST) )
{
lRowID = m_oQueryDataSetPIS.getInt("PIS_ID"); //I GET HERE lRowID =
30
m_oQueryDataSetPIS.deleteRow();
nDeleted = m_oQueryDataSetPIS.getDeletedRowCount(); // I GET HERE
nDeleted = 1
m_oPISDatabase.saveChanges(m_oQueryDataSetPIS); //HERE IS WHEN THE
EXCEPTION COMES

}
=====================================================================

The exception I have is :
com.borland.dx.dataset.DataSetException : BASE+51

Can someone help me...

Thanks in advance.

Paul