web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

A technique to select ax function from SQL - best practice.

(0) ShareShare
ReportReport
Posted on by

Hello,

I invited an architecture (seems a bit complicated one), that I can select an AX function as a culumn in SQL statment.

Something like:

Select dbo.displayMethod(tablename, methodname, dataareaid, recid) from ...

I used the following architecture (due some problems)

  • Create A CLR function in SQL server that call a web site (I didn't find a way calling WCF directly from SQL server. I think I shall install some components for that).
  • In the SQL server I add a new assembly, which is linked to dll of CLR function (Permission set: unrestricted - For that I need some privileges declaration on the server), and some function sthat connected to assembly.
  • The web site is on AOS server, which is best on REST API (MCV4 in VS 2010 - need to install that, since it for VS 2012 and above usually).
The REST API function has get method that call a service in AX. The method returns always a string, which is translated on the SQL server (in the functions - date, string, numeric, etc.)
  • There is unexplained problem (maybe some timeout declarations), that I created an instance of the WCF in the REST API function - and it stays available, so I need to create once, but sometimes (timeout?) the instance is not exist no more (even not null), so I run into exception, and need to create a new instance again and again - That's time consuming.
  • The WCF service on the AX is based on class that uses reflection (sysTable, sysDictionary, etc), and return the result to REST API function, which return that to string, and return back it to SQL server.

Some thing:

  • There maybe needless point (maybe I don't need the web site and REST API - just calling directly to WCF, but I didn't find a way doing that.
  • There is overhead (and time consuming) when I am falling into exception in REST API as described.
  • Don't know what technique is Microsoft supported - I need doing that much as best practice let me.
  • Is there other way doing that? Anyway that Microsoft provided?

Thanks :)

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,948 Most Valuable Professional on at

    It sounds like a silly idea to me from the very beginning. All queries will be so slow that they likely won't be usable for any practical purpose. Just think about all the network calls (one-by-one for each record), marshalling, reflection, calls from AX back to database to get the value of a display method and returning it back to the same database through a web service...

    In my opinion, you're seriously  abusing the database layer.

  • Community Member Profile Picture
    on at

    For a solution that returns a complicated AX function from SQL select statement - What is you suggestion?

  • Verified answer
    Martin Dráb Profile Picture
    237,948 Most Valuable Professional on at

    I'm not going to look for a solution how to call Dynamics AX from SQL queries, because it would always have similar problems. I'll keep AX business logic in the AX application layer.

    Use SQL for SQL stuff (including "complication functions", but SQL functions) and AX for AX stuff.

  • Community Member Profile Picture
    on at

    That's SQL select statement calls Dynamics-AX function.

    Is there there any connection in SQL-Server to Dynamics-AX AOS, so I can use it?

    Thanks :)

  • Verified answer
    Martin Dráb Profile Picture
    237,948 Most Valuable Professional on at

    No, it's not, of course. It would be a violation of the layered architecture.

  • Community Member Profile Picture
    on at

    OK.

    I have thought of alternative, which may be much more best-practice:

    Creating a data-warehouse that holds all of the complicated functions, but since I don't want to fill up again and again every run, I need to fill only the changes.

    Doing that is also very complicated - I don't know whether there is solution in AX for that?

    Thanks :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans