Hi, guys...I am trying to use fb 2.1.1 embed edition+ zeoslib 6.6.4 + delphi 7 in my project.
Today, I tried to understand how to delete a record or many records from a dataset.
Fistly, I put a tzconnection, tztable, datasource, dbgrid into my form and, then connected the database, it is ok, dbgrid showed all the data and, the next step was to click a button to delete the first record from database, as below:
{q is the name of tztable}
q.first;
q.delete;
Now, I could see the data was gone from the dbgrid, then the third step was to click another button which did below thing.
q.refresh;
Do you know what happened? The deleted first record was appeared in the dbgrid !!! I don't know the reason, it's driving me crazy...
I tried to use the bde's demo database without zeoslib and repeated the steps above, it is ok.
Help me!! Thank you!
I can't delete a record from fb 2.1.1 database with zeoslib!
Moderators: gto, cipto_kh, EgonHugeist
-
- Fresh Boarder
- Posts: 16
- Joined: 22.02.2009, 17:21
-
- Fresh Boarder
- Posts: 16
- Joined: 22.02.2009, 17:21
I don't know what's happened. Just 5 minutes ago, I rewrited the program, and result is ok. I am not sure where is the problem. The demo program was still a simple program.
I will try to recompile the zeoslib components, because I used a simplify version(without supporting other database, just left fb and ib) components before, it gave me a unwanted reason and, after that I recompiled and installed the full version of zeoslib...I guest and do not hope that is the reason.
I will try to recompile the zeoslib components, because I used a simplify version(without supporting other database, just left fb and ib) components before, it gave me a unwanted reason and, after that I recompiled and installed the full version of zeoslib...I guest and do not hope that is the reason.
-
- Junior Boarder
- Posts: 27
- Joined: 22.05.2008, 23:54
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
nostradumbass,
With zeoslib no special updates queries should be necessary to insert/update/delete records from a table when you're using a TZTable component.
There's the exception of a table without primary/unique keys. In those cases there's the risk of deleting/updating multiple rows by deleting/updating one row from the grid because it's impossible to automatically write a query which deletes/updates only one row.
The only reason I can think of why lukezeoslib had this strange effect was the cachedupdates setting that may have been different in the two tries.
Mark
With zeoslib no special updates queries should be necessary to insert/update/delete records from a table when you're using a TZTable component.
There's the exception of a table without primary/unique keys. In those cases there's the risk of deleting/updating multiple rows by deleting/updating one row from the grid because it's impossible to automatically write a query which deletes/updates only one row.
The only reason I can think of why lukezeoslib had this strange effect was the cachedupdates setting that may have been different in the two tries.
Mark
-
- Junior Boarder
- Posts: 27
- Joined: 22.05.2008, 23:54
-
- Fresh Boarder
- Posts: 16
- Joined: 22.02.2009, 17:21
Sorry, it's my failure.
After I could not use tztable + dbgrid to delete selected records or a record, I changed the components, I directly used the tzquery + tzupdatesql to do the same thing, it was ok. I don't know why, but I'm 100% sure that cacheupdates was set to 'false' in my demo program.
I don't know what was going on...you know, at first time, I used tzquery+tzupdatesql, but it could not delete the records, so I had to change to tztable, because I thought that tztable might be a full automatic component which did not need me to write 'delete sql', but the result was unexpected whatever deleteing a record or more records.
Another question is when I use tzupdatesql's sql editor ( by double click tzupdatesql component) to generate 'delete sql', it considers too much expression for 'delete sql', and the program shows a sql failure dialog to me as it is running.
Below is the 'delete sql' which created by tzupdatesql's sql editor automatically.
DELETE FROM warninglog
WHERE
warninglog.SE = :OLD_SE AND
warninglog.TREE = :OLD_TREE AND
warninglog.REGION = :OLD_REGION AND
warninglog.RACK = :OLD_RACK AND
warninglog.IP = :OLD_IP AND
((warninglog.FRAME IS NULL AND :OLD_FRAME IS NULL) OR (warninglog.FRAME = :OLD_FRAME)) AND
((warninglog.SLOT IS NULL AND :OLD_SLOT IS NULL) OR (warninglog.SLOT = :OLD_SLOT)) AND
((warninglog.CARDTYPE IS NULL AND :OLD_CARDTYPE IS NULL) OR (warninglog.CARDTYPE = :OLD_CARDTYPE)) AND
warninglog.WARNINGINFO = :OLD_WARNINGINFO AND
warninglog.DATETIME = :OLD_DATETIME
(warninglog.FRAME IS NULL AND :OLD_FRAME IS NULL)
---- this is one of the failure parts. Yes, the FRAME, SLOT, CARDTYPE are all allowed NULL in my database.
After I could not use tztable + dbgrid to delete selected records or a record, I changed the components, I directly used the tzquery + tzupdatesql to do the same thing, it was ok. I don't know why, but I'm 100% sure that cacheupdates was set to 'false' in my demo program.
I don't know what was going on...you know, at first time, I used tzquery+tzupdatesql, but it could not delete the records, so I had to change to tztable, because I thought that tztable might be a full automatic component which did not need me to write 'delete sql', but the result was unexpected whatever deleteing a record or more records.
Another question is when I use tzupdatesql's sql editor ( by double click tzupdatesql component) to generate 'delete sql', it considers too much expression for 'delete sql', and the program shows a sql failure dialog to me as it is running.
Below is the 'delete sql' which created by tzupdatesql's sql editor automatically.
DELETE FROM warninglog
WHERE
warninglog.SE = :OLD_SE AND
warninglog.TREE = :OLD_TREE AND
warninglog.REGION = :OLD_REGION AND
warninglog.RACK = :OLD_RACK AND
warninglog.IP = :OLD_IP AND
((warninglog.FRAME IS NULL AND :OLD_FRAME IS NULL) OR (warninglog.FRAME = :OLD_FRAME)) AND
((warninglog.SLOT IS NULL AND :OLD_SLOT IS NULL) OR (warninglog.SLOT = :OLD_SLOT)) AND
((warninglog.CARDTYPE IS NULL AND :OLD_CARDTYPE IS NULL) OR (warninglog.CARDTYPE = :OLD_CARDTYPE)) AND
warninglog.WARNINGINFO = :OLD_WARNINGINFO AND
warninglog.DATETIME = :OLD_DATETIME
(warninglog.FRAME IS NULL AND :OLD_FRAME IS NULL)
---- this is one of the failure parts. Yes, the FRAME, SLOT, CARDTYPE are all allowed NULL in my database.