1Ci Support Help Center home page
Submit a request
Sign in
  1. 1Ci Support
  2. 1C:Enterprise Development Standards
  3. Data processing
  4. Working with queries

Checking for an empty query result

  • Working with queries
    • Creating query texts
    • Multiple execution of the similar queries
    • Checking for an empty query result
    • Restriction on the use of FULL EXTERNAL CONNECTION structure in queries
    • Using UNION and UNION ALL words in queries
    • Ordering query results
    • Rounding arithmetic results in queries
    • Specifics of using LIKE operator in queries
    • Data source aliases in queries

Scope: managed applications, mobile applications, and ordinary applications.

1. If you need to check whether a query result is empty, employ the IsEmpty method. Otherwise, it will take time to fetch the data and save the result-set.

Incorrect:

Selection = Query.Execute().Select();
If Selection.Next() Then
  Return TRUE;
Else
  Return FALSE;
EndIf;

Correct:

Return NOT Query.Execute().IsEmpty()

Best practices

2. Do not embed IsEmpty when you need to fetch or import the query result.
Incorrect:

QueryResult = Query.Execute();
If NOT QueryResult.IsEmpty() Then // unnecessary call
  Selection = QueryResult.Select(); 
  While Selection.Next() Do
  ...

Correct:

Selection = Query.Execute().Select();
While Selection.Next() Do
...

© 2020 1C INTERNATIONAL LLC www.1Ci.com Support policy