How to catch the exceptions raised by Oracle from Navision

ajaybabuCh
Member Posts: 208
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
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
-
I don't think it's possible to catch exceptions in Navision.
You can write a vb com wrapper and excecute the code in there and catch the exception.0 -
In the past I've done this:
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.0 -
Thanq Joshi
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
AJayAjay0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions