Wrong parameters "+"

Common questions about 1C:Query language, Query builder tool and Data composition schema

#1
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Oct 29, 2012
Company:

Hello!

I'm trying to perform a concatenation of strings in a query, but receive the following error:

Code
{(3,15)}: Wrong parameters "+"
"Source: "+<<?>>CatalogFixedAssetActions.Comment AS Source

Here is my script:
Code
   Query = New Query;
   Query.Text = 
      "SELECT
      |   CatalogFixedAssetActions.Ref,
      |   ""Source: "" + CatalogFixedAssetActions.OriginalText AS Source
      |FROM
      |   Catalog.FixedAssetActions AS CatalogFixedAssetActions
      |WHERE
      |   CatalogFixedAssetActions.Parent = &Parent";

   Query.SetParameter("Parent", Catalogs.Dictionaries.FindByDescription("Desks", True, 
                                                   Catalogs.Dictionaries.EmptyRef()));
   Result = Query.Execute();

   SelectionDetailRecords = Result.Choose();

 
#2
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Nov 1, 2011
Company:

You can't concatenate unlimited strings

 
#3
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

This is not possible if Attribute OriginalText is Open-ended string.
Try set length for attribute (max: 1024)

Or I know two variants for resolve: do concatenation after query execution, or using calculated fields at datacompositionSchema

 
#4
People who like this:1Yes/0No
Active user
Rating: 3
Joined: Nov 1, 2011
Company:

Use SUBSTRING function to make it limited

Code
   Query.Text =
      "SELECT
      |   CatalogFixedAssetActions.Ref,
      |   ""Source: "" + SUBSTRING(CatalogFixedAssetActions.OriginalText, 1, 1000) AS Source
      |FROM
      |   Catalog.FixedAssetActions AS CatalogFixedAssetActions
      |WHERE
      |   CatalogFixedAssetActions.Parent = &Parent";­

 
#5
People who like this:0Yes/0No
Active user
Rating: 6
Joined: Sep 16, 2011
Company:

Or you can cast a string to a limited length one:

Code
   Query = New Query;
   Query.Text =
      "SELECT
      |   CatalogFixedAssetActions.Ref,
      |   ""Source: "" + CAST(CatalogFixedAssetActions.OriginalText AS String(1000)) AS Source
      |FROM
      |   Catalog.FixedAssetActions AS CatalogFixedAssetActions
      |WHERE
      |   CatalogFixedAssetActions.Parent = &Parent";

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks 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.