CONTAINTS in 1C Query

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Interested
Rating: 13
Joined: Nov 10, 2011
Company: 1A Software e.U

Hello!

I have this Query but I would like to use like in SQL CONTAINS:

Code
SEL ECT
   Addresses.Owner,
   Addresses.City,
   Addresses.State,
   Addresses.ZIP,
   Addresses.Owner.Description
FR OM
   Catalog.Addresses AS Addresses

ORDER BY
   Addresses.State DESC
CONTAINS "Trafik" //// ---- HERE I get an Error


Is there some similar to CONTAINS in 1C Platform?
Thank you for every advice!

Regards,
Lioudmila

 
#2
People who like this:0Yes/0No
Administrator
Rating: 5
Joined: Oct 3, 2019
Company:

Hello Lioudmila!

You need to use the following code:


Code
   Query = New Query;   
   
   Query.Text = 
      "SELECT
       |   Addresses.Owner AS Owner,
       |   Addresses.City AS City,
       |   Addresses.State AS State,
       |   Addresses.ZIP AS ZIP,
       |   Addresses.Owner.Description AS OwnerDescription
       |FROM
       |   Catalog.Addresses AS Addresses
       |WHERE
       |   Addresses.Description LIKE &Description
       |
       |ORDER BY
       |   State DESC"
      
   Query.SetParameter(Description, "%Trafik%");


Note the "%Trafik%":
if you use the symbol "%" - there can be any sequence of arbitrary characters;
if you use the symbol "_" - here is also any symbol, but only one.

Aleksandr

 
#3
People who like this:0Yes/0No
Interested
Rating: 13
Joined: Nov 10, 2011
Company: 1A Software e.U

Hello Aleksandr,

thanks a lot! It was not exactly what I needed because I have this Query in MainDataCompositionSchema.

Now it looks so:

Code

SEL ECT
   Addresses.Owner,
   Addresses.City,
   Addresses.State,
   Addresses.ZIP,
   Addresses.Owner.Description
FR OM
   Catalog.Addresses AS Addresses
WHERE Addresses.Owner.Description LIKE &Description   

ORDER BY
   Addresses.State DESC



and I made a Parameter Description (String) and in the Expession "%Trafik%".
It works!

Thanks a lot!
Regards
Lioudmila

 
Subscribe
Be the first to know tips & trick on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.