Re: ADO and DELETE Statement
- From: Skeeve <nospam@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 09 Jun 2006 11:57:30 -0400
On Thu, 8 Jun 2006 19:08:28 -0500, "Richard Mueller"
<rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx> wrote:
Hi,
Can you use transactions? The ADO connection object has BeginTrans,
CommitTrans, and RollbackTrans methods. Also, if an error is raised when the
delete fails, you should be able to trap that. In brief:
read record
BeginTrans
post purchase order
delete record
CommitTrans
If the CommitTrans method is never invoked because the delete failed, the
purchase order is never posted. Transaction rollbacks apply to INSERT,
UPDATE, and DELETE statements, but not SELECT, CREATE, ALTER, or DROP.
Well, I am doing this in Navision (Dynamics-NAV) using the MS ActiveX
Data Access lib. I have looked at all kinds of properties on the
connection object, nothing indicated an error status (same values,
regardless of success or failure).
To give you an idea of what I am doing, here is the relevant code
snippet:
sSql := '';
sSql := 'DELETE FROM Test_Warehouse_Transfer WHERE PO_No = ' +
'''' + 'P00000983' + '''';
SQL_Execute_Delete(sSql);
And then the function:
SQL_Execute_Delete(pInSQL : Text[1024])
IF ISCLEAR(adoRS2) THEN
CREATE(adoRS2);
adoRS2 := adoConnection.Execute(pInSQL);
temp1 := adoConnection.State;
//temp2 := adoRS2.RecordCount;
So the recordset is bascially empty because the DELETE operation
doesn't return a recordset.
The purchase order is posted in Navision. THat means that even if I
use the BeginTrans and CommitTrans in ADO and it fails, the PO is
still posted in Navision. It looks like this:
The first line is what posts the PO line in Navision. So if that
succeeds (TRUE is returned), I need to make 100% sure that the record
is deleted in SQL.
IF NOT lCuPostPO.RUN(lRecPO) THEN BEGIN
ERROR('Could not successfully post PO %1',lRecPO."No.");
END
ELSE BEGIN
// delete record from SQL
sSql := '';
sSql := 'DELETE FROM '+ gRecInventorySetup."Receiving
Confirmation" + ' WHERE CO = ' + '''' + COMPANYNAME() + '''';
sSql += ' AND Tag_No = ' + '''' + lTagNo + ''''; // The TAG
number from the receiving system is unique
SQL_Execute_Delete(sSql);
END;
Thanks for your help!
.
- Follow-Ups:
- Re: ADO and DELETE Statement
- From: Stephen Howe
- Re: ADO and DELETE Statement
- From: Richard Mueller
- Re: ADO and DELETE Statement
- References:
- ADO and DELETE Statement
- From: Skeeve
- Re: ADO and DELETE Statement
- From: Richard Mueller
- ADO and DELETE Statement
- Prev by Date: Re: SQL Server Timeout over the Network vs. Local
- Next by Date: Re: ADO and DELETE Statement
- Previous by thread: Re: ADO and DELETE Statement
- Next by thread: Re: ADO and DELETE Statement
- Index(es):
Relevant Pages
|
|