Can we use nested sql queries

vamsi_praneethvamsi_praneeth Member Posts: 23
edited 2008-08-26 in Dynamics AX
I actually have got a doubt regarding usaged of nested queries in Ax. Can we use nested queries or query with in a query in X++ ? Do X++ coding standards agree for nested queries?

Comments

  • MikerMiker Member Posts: 105
    Hi if you mention saying nested queries this:
    use Test
    select DISTINCT cust.Name 
    from CustTable as cust
    Where cust.Name in 
    	( select cust2.Name
    	  from CustTable as cust2
    	  where cust2.Address like '450000')
    


    than in Axapta you only be able do this:
    static void Job44(Args _args)
    {
        CustTable   Cust, Cust2;
        ;
        while select Name
        from Cust2
        where cust2.Address like '450000'{
            select Name
            from Cust
            Where cust.Name == cust2.Name;
                print Cust.Name;
        }
        pause;
    
    //    select Name from Cust where Cust.Name ==(select Name from Cust2 where Cust2.)
    
    }
    Use object Query you will get the same result
    going to Europe
  • HarishHarish Member Posts: 172
    Hi,

    Wherever possible I prefer to use dynamic queries. If used correctly, they can be significantly quicker than SQL queries. Please refer here for more info - http://www.axaptapedia.com/Expressions_in_query_ranges

    I hope this helps,
    Harish Mohanbabu
    Long way to go before I sleep..
  • MikerMiker Member Posts: 105
    hey can be significantly quicker than SQL queries
    Sql queries more quicker than Axapta queries :wink: , but it is not a best practice :D
    going to Europe
Sign In or Register to comment.