I am getting the following error trying to delete a record from InvoiceLine:
[QODBC] Requires at least one child. Cannot delete the last line (#10074)
Does the invoice file require that there be at least one record in InvoiceLine? If so, will delete the Invoice delete the InvoiceLine record?
Or - how do I get around the problem?
You can delete all records of Child tables. If all the records of child table e.g. InvoiceLine are deleted, the header record will not be of any use. If all the rows of a transaction are to be deleted, that means you would like to discard/delete the transaction. For deleting the transaction/invoice, delete the header row, and all its child records like InvoiceLine, Invoice linked transaction will be deleted automatically.
I think you have only one line item in an InvoiceLine table for that particular TxnId. QODBC / QuickBooks SDK cannot delete the last line item (invoice line having only 1 row left for the transaction/invoice) which is associated with the header a row of Invoice.
If you have multiple lines and would like to delete line items, then you need to provide InvoiceLineTxnLineID in where clause. You cannot use TxnNumber or TxnID because it is the same for all line items. But InvoiceLineTxnLineID is unique for each line item.
Please refer to the sample query:
DELETE FROM InvoiceLine WHERE InvoiceLineTxnLineID='376D-1264409144'
If you want to delete all line items, then you need to delete records from the header table.
DELETE FROM Invoice WHERE TxnNumber = 3444