Starting a NAV process from SQL. Ideas?

bbrown
Member Posts: 3,268
I have a few spots where I'm using ADO to fire off SQL processes from NAV. The example below is used to start a SQL index maintenence job following a nightly adjust cost. Since I never know how long Adjust Cost will run this cannot be simply scheduled. Instead I run the below code from the Adjust Cost process. This has been working fine. {a thanks to Waldo for some very helpful ADO examples}
Now I have the opposite situation. I need to start a NAV process after a SQL process completes. Anybody have some ideas on how this could be accompished. I was thinking of using NAS (possibly with message queue). Thoughts?
Now I have the opposite situation. I need to start a NAV process after a SQL process completes. Anybody have some ideas on how this could be accompished. I was thinking of using NAS (possibly with message queue). Thoughts?
OnRun() IF ISCLEAR(ADOConnection) THEN; CREATE(ADOConnection); ADOConnection.ConnectionString := GetConnectionString; ADOConnection.Open; IF ISCLEAR(ADOCommand) THEN CREATE(ADOCommand); lvarActiveConnection := ADOConnection; ADOCommand.ActiveConnection := lvarActiveConnection; ADOCommand.CommandText := 'sp_start_job'; ADOCommand.CommandType := 4; ADOCommand.CommandTimeout := 0; ADOParameter := ADOCommand.CreateParameter('@job_name', 200, 1, 50, GLSetup."Index Job Name"); ADOCommand.Parameters.Append(ADOParameter); ADOCommand.Execute; ADOConnection.Close; GetConnectionString() : Text[1024] GLSetup.GET; GLSetup.TESTFIELD("Server Name"); GLSetup.TESTFIELD("Index Job Name"); ConnectString := 'Driver={SQL Native Client};' + 'Server=' + GLSetup."Server Name" + ';' + 'Database=msdb;Trusted_Connection=yes;'; EXIT(ConnectString);
There are no bugs - only undocumented features.
0
Comments
-
You will definitely need NAS. How to activate it - more ways:
1) WebService (I hope that it is possible to call WS from SQL procedure, definitely yes, if you create the procedure in Visual Studio...)
2) Some flag in some table (NAS will periodically check the flag, SQL will set the flag)
3) MSMQ0 -
Thanks for the reply.
The site is 5.0 SP1 so option 1 is currently not an option. Options 2 and 3 are both possibilities. Another option I'm thinking about is using a Job Queue (a variatio of NAS) task that fires off and watches a table for a specific record, then continues on once it finds that record. This would be similar to your option 2. This process only needs to run once a week (on the weekend) and it does not need to be immediately after the SQL process. If there was a short delay it would be fine. The issue is more not having someone needing to hang around till the SQL process completes, so they can start the NAV process.There are no bugs - only undocumented features.0 -
1 is option for NAV 5.0 too. It is options for all versions having NAS. It is not problem to create DLL to be able to use NAS as WebService provider. Just search the forum or internet, there are posts and blog about how to create WebServices for older versions of NAV.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