Contents tagged with BQL

  • How to construct complicated queries in BQL of Acumatica

    Hello everybody,

    today I want to describe the following situation. Imagine that you have to write following SQL statement in Acumatica:

    SELECT InventoryItem.InventoryCD, InventoryItem.imageUrl, UploadFile.Name, NoteDoc.FileId, * FROM InventoryItem

    LEFT JOIN UploadFile ON InventoryItem.imageUrl = UploadFile.Name

    LEFT JOIN NoteDoc ON UploadFile.FileID = NoteDoc.FileID where imageurl is not null

    I myself prefer to have way to write a code that is easy to modify and maintain. So instead of creating one big BQL statement I'd like to make it as few smaller statements. Is it achievable with Acumatica BQL? Yes, it's achievable. Take a look at following code that does exactly what I've … more

  • How to set command time out part 2

    Hello everybody,

    today I want to document few ways on how to modify command time out. Sometime it may happen that you have some kind of long runnig queries, and at some particular graph you may want to make it live longer. 

    For such purposes very convenient is PXCommandScope object. Below goes code sample that allow you to achieve this purpose:

     using (new PXCommandScope(PXDatabase.Provider.DefaultQueryTimeout * 2))  // increasing 2 fold {               var results = PXSelect<BAccount>.Select(this); }

    with such code you can get twice a time for your BQL statements.  more

  • Operator IN in BQL

    Hello everybody,

    today I want to write a few words about operator in which was presented in SQL for long ago, but weren't available in Acumatica BQL. But time goes on and now you can use it. For example like this:

    Object[] values = new String[] { "BXW000004", "BXW000005" };

                    POOrder item = PXSelect<POOrder,

                        Where<POOrder.orderNbr, In<Required<POOrder.orderNbr>>>>.Select(Base, values);

    that code will generate following sql statement:

    Select * from POOrder POOrder Where POOrder.OrderNbr In ('BXW000005', 'BXW000004')

    Order by POOrder.OrderNbr

    I can say that such approach simplifies some tasks that require dynamic passing of arguments.

    more