locked
Hi please help with syntax error "DCACCOUNTSOLD" without " " it runs and not give back results RRS feed

  • Question

  • "select * 

    from db2

    where convert(varchar(10), createtime, 112) between @fromdate and @todate 
    and convert(xml, replace(message, 'exp:', ' ')).exist('RequestDocument/DocumentRequest/documentType[.="DCACCOUNTSOLD"]')=1"

    Error in the component's properties:The operator * is undefined for the argument type(s) java.lang.String, java.lang.String

    Syntax error on token "DCACCOUNTSOLD", * expected


    Wednesday, June 24, 2020 9:50 AM

All replies

  • In which way is this related to MS SQL Server, the topic of this forum? The error message comes from Java.

    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Wednesday, June 24, 2020 9:52 AM
  • Do you have any idea to the answer? you can advice to which forum i can put my question. but for now i'm expecting an answer. 
    Wednesday, June 24, 2020 10:16 AM
  • exist('RequestDocument/DocumentRequest/documentType[.="DCACCOUNTSOLD"]')=1

    Error in the component's properties:The operator * is undefined for the argument type(s) java.lang.String, java.lang.String
    Syntax error on token "DCACCOUNTSOLD", * expected
    • Merged by Olaf HelperMVP Wednesday, June 24, 2020 10:26 AM Same question from same OP
    Wednesday, June 24, 2020 10:19 AM
  • Wednesday, June 24, 2020 1:52 PM
  • Not that I know Java, but the problem is quite apparent. The SQL string is embraced in double quotes in your Java code. But the SQL string itself includes double quotes, so Java takes the string to be:

     "select * 
     from db2
     where convert(varchar(10), createtime, 112) between @fromdate and @todate 
     and convert(xml, replace(message, 'exp:', ' ')).exist('RequestDocument/DocumentRequest/documentType[.="

    And then the next token that comes after the string is DCACCOUNTSOLD. Which I guess does not parse well in Java.

    You must find out how include double quotes in Java. As I said, I don't know Java, but in SQL, Pascal and several other languages you double the delimiter, so in that case it would be ""DCACCOUNTSOLD"". In several other languages, including all based on C, you use backslash as an escape: \"DCACCOUNTSOLD\". I believe that Java has its roots in C and C++, so I would place my bets on the backslash.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

    • Proposed as answer by Naomi N Wednesday, June 24, 2020 10:52 PM
    Wednesday, June 24, 2020 9:44 PM
  • From wikipedia:

    > "The syntax of Java is similar to C and C++, but it has fewer low-level facilities than either of them."

    I assume backslash is the solution :-) 

    Nhlahla Mike, Please don't open duplicate threads next time. You started three similar thread for some reason, and this abuse the people that come to help on there free time and need to deal with three thread and maybe continue the discussion when it was already closed in the other thread.

    Thanks


    signature   Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]    [Linkedin]


    • Edited by pituachMVP Thursday, June 25, 2020 9:14 AM
    Thursday, June 25, 2020 9:12 AM