AX Query ( can anybody Review this Query )

HI , can anybody review this Query ?

Select all items in saleslines that has a configuration(inventory dimension) specified in transactions

SalesLine salesLine;

InventDim inventDim;

InventTable inventTable;

;

while select inventTable

exists join salesLine

where salesLine.ItemId == inventTable.ItemId

exists join inventDim

where inventDim.inventDimId == salesLine.InventDimId

&& inventDim.configId != ’ ’

{

info(salesLine.ItemId);

}

}

Hi Jagaddish,

I dont have any idea why you are taking inventtable in to the loop. Instead you can write the query like this :

while select salesline

exists join inventtrans

where salesline.itemid == inventtrans.itemid

exists join inventdim

where inventtrans.inventdimid== inventdim.inventdimid

&& inventDim.configId

{

info(salesline.ItemId);

}

Thank You Vishal…

:slight_smile:

HI ,

How can i use , delete_from , forupdate and delete commands in QueryObject ax 2009…

can we have any static Queryclasses to perform above operaions like (OrderMode,Selection FIeld …etc.).

Hi Jagaddish,

Generally query (qbds) can be written in order to filter the data in forms.

Or some complex repoort or enquiry purpose you can initiate writing Queryclasses code.

But for deletion, you can use simple select statement.

And the query class can also be used to clear the ranges in your form (using clearranges()).

Thank You Vishal…

HI vishal …

you are suggested me that , use normal select statement to perform delete operation…so i have written the query object like the below.

could you please verify it…

while( queryExecuter.next())

{

salesTable = queryExecuter.get(tablenum(SalesTable));

delete_from salesTable;// it’s not working

salesTable.delete();// it 's working

info(“Orphan records are deleted”);

}