Subject deleting problem with tiboquery
Author rodbracher
OK - this is a long one but I just cant see whats wrong.
I have a twwDBGrid, its dataSource being a tiboQuery (name : sale ).
The query selects sales captured on todays date.

Now when I insert a new sale ( on a modal form ) and click 'OK' the
grid is updated correctly and the sale appears on the grid. If I
delete the sale (using sale.delete), the sale dissapears from the
grid. If I close the grid form and reopen it, the sale reappears !
Now if I delete the sale it is deleted properly.

To make sure I wasnt going mad in the head, I captured the SQL with
SQL Monitor. Here is the SQL for each instance I pressed the 'Delete'
button. From this is is clear the first time the sale is not actually
being deleted (why it dissappers from the grid I dont know )

1st Delete :

SELECT ALL sale.*
FROM sale
WHERE customer /*<*/ >= ? /* "OLNK_customer" */
ORDER BY customer ASC
, saledate ASC

PLAN (SALE ORDER SALE_CUSTDATE_KEY)

FIELDS = [ Version 1 SQLd 20 SQLn 30
SALE.SALE = <NIL>
SALE.SALEDATE = <NIL>
SALE.PRODUCT = <NIL>
SALE.POINTS = <NIL>
SALE.SERIAL = <NIL>
SALE.DEALER = <NIL>
SALE.SALESREP = <NIL>
SALE.CUSTOMER = <NIL>
SALE.CAPTURE = <NIL>
SALE.LETTER = <NIL>
SALE.PRINT = <NIL>
SALE.EMAIL = <NIL>
SALE.MANAGER = <NIL>
SALE.NEXTCAT = <NIL>
SALE.PRINTDATE = <NIL>
SALE.SALETYPE = <NIL>
SALE.USERCODE = <NIL>
SALE.PRINTUSER = <NIL>
SALE.WARRANTY = <NIL>
SALE.SPECIAL = <NIL> ]

SECONDS = 0.010
----*/
/*---
EXECUTE STATEMENT
TR_HANDLE = 17258320
STMT_HANDLE = 27690288
PARAMS = [ Version 1 SQLd 1 SQLn 1
[OLNK_CUSTOMER] = -2147483648 ]


2nd Delete :

delete from SALE
where
SALE = ? /* OLD_SALE */

PLAN (SALE INDEX (RDB$PRIMARY21))

FIELDS = [ Version 1 SQLd 0 SQLn 30 ]
----*/
/*---
EXECUTE STATEMENT
TR_HANDLE = 17258320
STMT_HANDLE = 27838588
PARAMS = [ Version 1 SQLd 1 SQLn 1
[OLD_SALE] = 38235 ]

SELECT COUNT: 1
DELETE COUNT: 1

SECONDS = 0.010
----*/
/*---
EXECUTE STATEMENT
TR_HANDLE = 17258320
STMT_HANDLE = 27805580
PARAMS = [ Version 1 SQLd 1 SQLn 1
[OLNK_CUSTOMER] = -2147483648 ]

SECONDS = 0.010
----*/


(I left out some of the 'Execute statement' ... etc stuff.)

Why do I not get a delete... query the first time round ?