Board index » jbuilder » QueryDataSet.deleteAllRows fails

QueryDataSet.deleteAllRows fails


2006-12-07 05:53:00 PM
jbuilder24
I'm trying to empty a table with the following code (some lines
regarding metadataupdate, tablename and rowid removed for brevity):
queryDataSet1.setQuery(new QueryDescriptor(database1, "select *
from some_table", null, false,Load.ALL));
queryDataSet1.setResolver(new QueryResolver());
queryDataSet1.executeQuery();
queryDataSet1.deleteAllRows();
queryDataSet1.saveChanges();
The code raises a runtime DataSetException, error code BASE+38:
More than one row was affected by resolution query:DELETE FROM
`some_table` WHERE `CaseID` = ?
I'm stumped. The resolution query seems OK. Did I forget something
obvious?
Thanks in advance,
Wim
 
 

Re:QueryDataSet.deleteAllRows fails

Whym,
Frankly I would never have included the line..
queryDataSet1.setResolver(new QueryResolver());
I default resolver is created as part of the QueryDataSet. Unless you
require special resolution functions (which seems you do not) I don't
see a reason for that line, (and it may be mucking things up..??)
Another possible addition is:
queryDataSet1.setRowId("CaseID", true);
It could be that the driver you are using is not reporting the metadata
correctly and therefore you need to give DX a bit more help. Otherwise
It will use ALL or SOME rows to locate the desired record to delete that
are not really key fields, depending on what has been reported by the
driver. This is not a DX problem but a driver issue.
John...
Whym Junction wrote:
Quote
I'm trying to empty a table with the following code (some lines
regarding metadataupdate, tablename and rowid removed for brevity):


queryDataSet1.setQuery(new QueryDescriptor(database1, "select *
from some_table", null, false,Load.ALL));
queryDataSet1.setResolver(new QueryResolver());
queryDataSet1.executeQuery();
queryDataSet1.deleteAllRows();
queryDataSet1.saveChanges();

The code raises a runtime DataSetException, error code BASE+38:
More than one row was affected by resolution query:DELETE FROM
`some_table` WHERE `CaseID` = ?

I'm stumped. The resolution query seems OK. Did I forget something
obvious?

Thanks in advance,
Wim

--
=============================================
TeamB are volunteer helpers. Please DO NOT REPLY VIA EMAIL!
Post all questions and replies to this newsgroup ONLY
For papers on DataExpress, Applets, JSP, and Web Development go to:
www.microps.com/mps/paperFAQ.html
====================================================
 

Re:QueryDataSet.deleteAllRows fails

Hi John,
Thanks for your helpful advice. I'm still learning to use the dx
library.
I found a solution for this problem. There were had duplicate records
in my dataset, and there was no key set. Dx breaks the above query into
smaller pieces; it tries to delete records one at a time. The solution
is to make sure the records are different in at least one field or by
adding a unique key field. I'll report here if I find a way to prevent
the one-at-a-time delete strategy.
Thanks again,
Wim
John Moore (TeamB) schreef:
Quote
Whym,

Frankly I would never have included the line..

queryDataSet1.setResolver(new QueryResolver());

I default resolver is created as part of the QueryDataSet. Unless you
require special resolution functions (which seems you do not) I don't
see a reason for that line, (and it may be mucking things up..??)

Another possible addition is:

queryDataSet1.setRowId("CaseID", true);

It could be that the driver you are using is not reporting the metadata
correctly and therefore you need to give DX a bit more help. Otherwise
It will use ALL or SOME rows to locate the desired record to delete that
are not really key fields, depending on what has been reported by the
driver. This is not a DX problem but a driver issue.

John...


Whym Junction wrote:
>I'm trying to empty a table with the following code (some lines
>regarding metadataupdate, tablename and rowid removed for brevity):
>
>
>queryDataSet1.setQuery(new QueryDescriptor(database1, "select *
>from some_table", null, false,Load.ALL));
>queryDataSet1.setResolver(new QueryResolver());
>queryDataSet1.executeQuery();
>queryDataSet1.deleteAllRows();
>queryDataSet1.saveChanges();
>
>The code raises a runtime DataSetException, error code BASE+38:
>More than one row was affected by resolution query:DELETE FROM
>`some_table` WHERE `CaseID` = ?
>
>I'm stumped. The resolution query seems OK. Did I forget something
>obvious?
>
>Thanks in advance,
>Wim
>


--
=============================================
TeamB are volunteer helpers. Please DO NOT REPLY VIA EMAIL!
Post all questions and replies to this newsgroup ONLY
For papers on DataExpress, Applets, JSP, and Web Development go to:
www.microps.com/mps/paperFAQ.html
====================================================
 

{smallsort}

Re:QueryDataSet.deleteAllRows fails

Whym Junction wrote:
Quote
I found a solution for this problem. There were had duplicate records
in my dataset, and there was no key set.
You should definitely fix that.. poor database design..
Quote
Dx breaks the above query into
smaller pieces; it tries to delete records one at a time. The solution
is to make sure the records are different in at least one field or by
adding a unique key field. I'll report here if I find a way to prevent
the one-at-a-time delete strategy.
Consider stored procedures..
I would never dream of using "deleteAll" except on a very, very small
table..
John..
--
=============================================
TeamB are volunteer helpers. Please DO NOT REPLY VIA EMAIL!
Post all questions and replies to this newsgroup ONLY
For papers on DataExpress, Applets, JSP, and Web Development go to:
www.microps.com/mps/paperFAQ.html
====================================================