|
| Iniciado por guest, 11,mar. 2015 08:40 - 2 respuestas |
| |
| | | |
|
| |
| Publicado el 11,marzo 2015 - 08:40 |
Hi guys! Does anyone met with this situation? I have a TABLE control that display result of SQL query (non-embedded) where I need to delete a record. After reading documentation I do so: RecordToDelete is int = HRecNum(QRY_Query) In result RecordToDelete contains invalid record number - it is not match to the real record in the file and record with other record number is deleted.
HDelete(File,RecordToDelete) - incorrect record is deleted HDelete(QRY_Query,RecordToDelete) - record is not deleted
Is it bug or "feature"? |
| |
| |
| | | |
|
| | |
| |
| Publicado el 11,marzo 2015 - 10:03 |
Arekusei
HRecNum(QRY_Query) returns the number of records found (fetched) by the query not the id of the record.
You need to find the record id.
lnRow is int = TableSelect(MyTable) RecordToDelete is int = QRY_Query[lnRow].idRecord OR RecordToDelete is int = MyTable.idRecord
The query and table display are in memory so you will need to load the selected record from the DB. HReadSeekFirst(MyFile,MyNdx,RecordToDelete) HDelete(MyFile,hCurrentRec) |
| |
| |
| | | |
|
| | |
| |
| Publicado el 11,marzo 2015 - 12:28 |
Hi,
hRecNum on a query returns a sequential number, (counting from 1) that does not correspond to the physical recordnumber. The physical recordnumber cannot be retrieved in a query. So you cannot delete a record from the file directly, unless your query contains a unique key to look for the record. You can delete the record directly from the query, but that will only work if your query is a single file query AND if the query has been executed using the hModifyFile parameter.
Regards, Piet |
| |
| |
| | | |
|
| | | | |
| | |
|