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

Data source aliases in queries

  • 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. Data source aliases must clearly state their purpose. Requirements for source aliases are similar to the requirements for variable names in the code.

  • Create aliases using industry-specific terms to clearly understand how the data source will be used in queries.
  • Create aliases by deleting spaces between words. In this case, every word in the name is capitalized (for example, GoodsAndServices). Prepositions and pronouns consisting of one letter need to be capitalized as well.
  • Avoid starting alias names with an underline.
  • Aliases must not consist of one character.

Incorrect:

SELECT
  Table1.Ref AS Goods,
  IsNULL(Table2.CountBalance, 0) AS Balance
FROM
  Catalog.Products AS Table1
    LEFT JOIN AccumulationRegister.Stock.Balance AS Table2
    BY Table1.Ref = Table2.Products

Correct:

SELECT
  AllProducts.Ref AS Goods,
  IsNULL(WarehouseBalance.CountBalance, 0) AS Balance
FROM
  Catalog.Products AS AllProducts
    LEFT JOIN AccumulationRegister.WarehouseBalance.Balances AS WarehouseBalance
    BY AllProducts.Ref = WarehoseBalance.Products

In particular, we do not recommended that you use names of metadata object classes ("Catalog", "Document", and other) as such aliases will not show the source purpose in a particular query.

2. You can use universal aliases upon developing universal tools to work with arbitrary data tables or upon writing universal queries, when a particular table name is inserted instead of the data source upon code execution.

Example:

"SELECT
  Table.Description AS Description
  Table.Code AS Code
FROM
  &Table AS Table";

QueryText = StrReplace(QueryText , "&Table", "Catalog." + CatalogName);

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