🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.database
4 messages
4 total messages Started by Whym Junction Thu, 07 Dec 2006 09:53
QueryDataSet.deleteAllRows fails
#369
Author: Whym Junction
Date: Thu, 07 Dec 2006 09:53
20 lines
1802 bytes
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
#370
Author: John Moore (TeamB)
Date: Fri, 08 Dec 2006 21:15
54 lines
2788 bytes
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
====================================================
Re: QueryDataSet.deleteAllRows fails
#371
Author: Whym Junction
Date: Tue, 12 Dec 2006 08:38
72 lines
3751 bytes
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:

> 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
> ====================================================
Re: QueryDataSet.deleteAllRows fails
#372
Author: John Moore (TeamB)
Date: Tue, 12 Dec 2006 19:50
28 lines
2015 bytes
Whym Junction wrote:

> 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..


> 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
====================================================
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads