Hi
I am Ajay.
The folowing is the automation variabl.
ADO-- 'Microsoft ActiveX Data Objects 2.7 Library'.Connection
By using the above automation , I connected to the Oracle 10g and
I am inserting the records from navision to Oracle 10g
The following is the code to insert the records from navision to Oracle10g
I am inserting the Vendor ledger entries.
ADO.Execute(
'INSERT INTO BATCHTRANS (BATCHTRANS,TRANSTYPE,TRANSNO,CONTACT,LONGDESCRIPTION,TRANSAMT,TRANSDATE,CRNCY) VALUES('+
FORMAT(VendorLedgerEntry."Entry No.")+','+FORMAT(TypeVar)+','''+VendorLedgerEntry."Document No."+''','''+
VendorLedgerEntry."Vendor No."+''','''+VendorLedgerEntry.Description+''','+
DELCHR(FORMAT(VendorLedgerEntry.Amount),'=',',')+',to_date('''+
FORMAT(VendorLedgerEntry."Posting Date")+''',''dd/mm/yy''),'''+VendorLedgerEntry."Currency Code"+''');');
Problem :
The problem is , If I have 5 vendor ledger entries to insert. and suppose that i inserted 3 vendor ledger entries successfully, then at the 4th record
Oracle raised an exception during some problem.
I want to catch that exception from navision and I want to skip that 4th record and want to continue with inserting the remaining records.
I don't want to break the process when Oracle raised the exception.
Could anybody please help me to catch the exceptions or errors raised by the Oracle.
Regards
ajay
Ajay
0
Comments
You can write a vb com wrapper and excecute the code in there and catch the exception.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
created a single instance codeunit that only has the sqlconnection.execute() command in the onrun trigger.
the codeunit has getter and setter functions to set the command string, and anything else you need to do.
you call if codeunit.run to "catch" the errors. This doesn't give you an error code, but I've never really needed to know, programatically, what the error was. I usually just output the sql to a text log file if there is problem, and analyze it later.
however, I vaguely remember there being an attribute in the ado connection object with an error code in it. If so, you shoudl be able to poll that and find out what went wrong if you want to programatically handle the errors.
I did the same. I splited my code and put in different codeunits. if any
code unit fails during execution i just put the oracle record in my log file
and continue with next record.
like ..
IF NOT CODEUNIT.RUN() THEN
WRITE TO LOG FILE.
Regards
AJay