STRING concatenation isn't recognized

Any idea why this concatenation is refused with error on the “+” character:
mismatched input. expecting {’,’ , ‘;’}

STRING keyDomain = "domain-" + domainName;

The domainName variable is received as a STRING argument to the query:

CREATE QUERY insertDomainWithRulesSet(STRING domainName, ...

The following also fails on the trim:

STRING keyPerson = trim(lower(firstName));

What am I missing with those simple string operators and functions?

Thanks!

These problems could be that the initialisation of variables is not always good at doing more than applying a constant. You may have to do something like:

STRING keyDomain = "domain-";
keyDomain = keyDomain + domainName;

and:

STRING keyPerson;
keyPerson = trim(lower(firstName));

Thanks rik.
I can’t get out of it. It is inconsistent.
In one instance, it works.

I can’t get it to work on other queries.

As you can see, breaking as you suggested merely shifted the error on the STRING qualifier:

It happens on other queries.

I’m starting to feel it’s some bug in the editor. Can you reproduce this on your Graph Studio? Here’s the complete query to copy:

CREATE QUERY insertDomainWithRulesSet(STRING domainName,  
  UINT problemsSequenceToResolveSkill, UINT problemsCountToResolveSkill,
  FLOAT successRateToResolveSkill, FLOAT failedProblemPercentInSkillBeforeLesson,
  BOOL breakEvalBySection, UINT countQuestionsEvalSubject,
  UINT countQuestionsEvalTopic, UINT countQuestionsEvalChapter,
  UINT countQuestionsEvalTrip, INT evalPolicy, FLOAT evalPolicyValue1, FLOAT evalPolicyValue2,
  UINT failedProblemsSequenceToRegressSkill, FLOAT problemToLessonRatio,
  FLOAT spacedRepetitionFactor, UINT countProblemType,
  UINT problemTimeOutAlert, UINT problemTimeOutTerminate) FOR GRAPH SkillBlasterDev { 
  
    UINT rulesSetIndex = 1;
    INT domainStatus = 1; //1=Active
    
    STRING keyDomain = "domain-";
    keyDomain = keyDomain + trim(lower(domainName));
    
    STRING keyRulesSet;
    keyRulesSet = "niarulesset-";
    keyRulesSet = keyRulesSet + trim(lower(domainName));
    keyRulesSet = keyRulesSet + "-" + to_string(rulesSetIndex);
    
    //Insert Domain
    INSERT INTO Domain (PRIMARY_ID, Name, Status, ActiveRulesSetIndex) VALUES (
      keyDomain, domainName, domainStatus, rulesSetIndex
    );
    
    //Insert NIARulesSet
    INSERT INTO NIARulesSet (PRIMARY_ID, RulesSetIndexInDomain, ProblemsSequenceToResolveSkill,
      ProblemsCountToResolveSkill, SuccessRateToResolveSkill, FailedProblemPercentInSkillBeforeLesson,
      BreakEvalBySection, CountQuestionsEvalSubject, CountQuestionsEvalTopic, CountQuestionsEvalChapter,
      CountQuestionsEvalTrip, EvalPolicy, EvalPolicyValue1, EvalPolicyValue2, 
      FailedProblemsSequenceToRegressSkill, ProblemToLessonRatio, SpacedRepetitionFactor, 
      CountProblemType, ProblemTimeOutAlert, ProblemTimeOutTerminate) VALUES (
        keyRulesSet,
        rulesSetIndex, 
        problemsSequenceToResolveSkill, 
        problemsCountToResolveSkill, 
        successRateToResolveSkill, 
        failedProblemPercentInSkillBeforeLesson,
        breakEvalBySection, 
        countQuestionsEvalSubject,
        countQuestionsEvalTopic, 
        countQuestionsEvalChapter,
        countQuestionsEvalTrip, 
        evalPolicy, 
        evalPolicyValue1, 
        evalPolicyValue2,
        failedProblemsSequenceToRegressSkill, 
        problemToLessonRatio,
        spacedRepetitionFactor, 
        countProblemType,
        problemTimeOutAlert, 
        problemTimeOutTerminate
    );
    
    //Insert edge connecting Domain and NIARulesSet
    INSERT INTO hasRulesSet (FROM, TO) VALUES (
      keyDomain,
      keyRulesSet
      );
    
  PRINT keyDomain; 
}

SOLVED.
To be precise: worked-around…

I had to push all declarations of the variables (without assignment) to the beginning of the query (even before declaring EXCEPTIONS).

Thanks for your support!
Mor

1 Like

Glad to help, if only a little :slight_smile: The “declarations at the top” thing is a bit old fashioned (versus Java, say), but unlikely to change any time soon. I might ask the question of product though.