Linked table query

hav
Member Posts: 299
Hi All,
I have two databases on my SQL Server instance.
--> WMDATA : third party database
--> Demo Database NAV (6-0) : NAV 2009 demo database
The WMDATA database contains a table WMTracking.
I have created a view 'CRONUS International Ltd_$WMTracking' using SQL Server 2005 in NAV demo database. The definition of the view is as follows:
CREATE VIEW [CRONUS International Ltd_$WMTracking]
AS SELECT * FROM WMDATA.dbo.WMTracking
Note that the source table of the view is WMTracking table of WMDATA db.
I then created a table WMTracking in NAV having LinkedObject property set to Yes so that the table is linked to the view.
When i run a thrid party application, tracking transactions are generated and stored in WMTracking table of WMDATA db. This in turn also generates the record in WMTracking view and then WMTracking table of NAV demo db.
The problem i face is:-
I want to do some processing when a record is inserted in WMTracking table in NAV. For this i have written some code in OnInsert() trigger of WMTracking linked table in NAV and what i noticed is that the trigger is not executed when a new record is inserted although by the third party application.
The question is why does the trigger not executed when a record is inserted in WMTracking linked table?
Please help.
Regards,
Hemant
I have two databases on my SQL Server instance.
--> WMDATA : third party database
--> Demo Database NAV (6-0) : NAV 2009 demo database
The WMDATA database contains a table WMTracking.
I have created a view 'CRONUS International Ltd_$WMTracking' using SQL Server 2005 in NAV demo database. The definition of the view is as follows:
CREATE VIEW [CRONUS International Ltd_$WMTracking]
AS SELECT * FROM WMDATA.dbo.WMTracking
Note that the source table of the view is WMTracking table of WMDATA db.
I then created a table WMTracking in NAV having LinkedObject property set to Yes so that the table is linked to the view.
When i run a thrid party application, tracking transactions are generated and stored in WMTracking table of WMDATA db. This in turn also generates the record in WMTracking view and then WMTracking table of NAV demo db.
The problem i face is:-
I want to do some processing when a record is inserted in WMTracking table in NAV. For this i have written some code in OnInsert() trigger of WMTracking linked table in NAV and what i noticed is that the trigger is not executed when a new record is inserted although by the third party application.
The question is why does the trigger not executed when a record is inserted in WMTracking linked table?
Please help.
Regards,
Hemant
Regards,
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
0
Answers
-
You pretty much answer your question...
The Navision triggers that you wrote is executed by the Nav application.
The trigger is stored in Nav, not the SQL db.
You will either need to write a SQL trigger or a trigger in your third party app.0 -
Hi!
Instead of the NAV Trigger, maybe you could create a small function which periodically checks (Timer, NAS, Job Scheduler) for new entries in this "Linked Object" Table to start the processing then?
This should be easy; maybe when the record is inserted into the WMDATA database a flsg (e.g. "Processed") is set to FALSE, then in NAV you could filter on those records for processing ...
Regards,
JörgJörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool0 -
There needs to be a an active NAV instance to actually executate any of the business logic that you want it too. As discussed here it's possible to have a report/codeunit run via job queue or on some timer that executes the logic that you want it to.
Another option would be to use SQL to call NAV directly (assumes you are running a full blown NAV 2009 RTC environment with an application server). Basically the idea is to have your WMData database make calls to NAV when events happen - and use the new Web Service functionality of NAV 2009 to execute your logic.
1) Build a Page or Codeunit in NAV that exposes a function with your business logic in it
2) Update the WMTracking table in the WMData databse with an insert trigger that invokes some managed .Net code
3) in this .Net trigger - call the NAV web service and perform any required tasks
Good example for connecting to NAV as a web service: https://community.dynamics.com/blogs/navdavidroys/comments/31769.aspx0 -
Hi,
Thanks for your support.
I have decided to use a job queue to schedule a codeunit at regular interval. The codeunit will execute the required business logic.
Regards,
HemantRegards,
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)0
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