Main > Forum > 1C:Enterprise Platform > 1C:Query language and DCS > Wrong parameters "+"

Forum

Search UsersRules
Wrong parameters "+"
#1
Active user
Points:: 0
Joined:: Oct 29, 2012

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();

Profile
#2
Active user
Points:: 0
Joined:: Nov 1, 2011

You can't concatenate unlimited strings

Profile
#3
Active user
Points:: 0
Joined:: Sep 26, 2012

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

Profile
#4
Active user
Points:: 0
Joined:: Nov 1, 2011

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";­

Profile
#5
Active user
Points:: 2
Joined:: Sep 16, 2011

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";

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.