 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Whym Junction Guest
|
Posted: Thu Dec 07, 2006 3:53 pm Post subject: QueryDataSet.deleteAllRows fails |
|
|
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 |
|
| Back to top |
|
 |
John Moore (TeamB) Guest
|
Posted: Sat Dec 09, 2006 3:15 am Post subject: 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:
http://www.microps.com/mps/paperFAQ.html
==================================================== |
|
| Back to top |
|
 |
Whym Junction Guest
|
Posted: Tue Dec 12, 2006 9:13 am Post subject: 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:
http://www.microps.com/mps/paperFAQ.html
==================================================== |
|
|
| Back to top |
|
 |
John Moore (TeamB) Guest
|
Posted: Wed Dec 13, 2006 1:50 am Post subject: 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:
http://www.microps.com/mps/paperFAQ.html
==================================================== |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|