0

I was given some SQL to run against our db and it is throwing a syntax error. I have looked through and cannot find the missing expression. Can anyone please assist? It says line 6 column 42, which correlates to the first "ts".

Thanks, Andrew

SELECT "IWRKGRPQUEUESTATS"."CNAME", "IWRKGRPQUEUESTATS"."CHKEY3", "IWRKGRPQUEUESTATS"."NENTEREDACD", "IWRKGRPQUEUESTATS"."NINTERNTOEXTERNCALLS", "IWRKGRPQUEUESTATS"."NANSWEREDACD", "IWRKGRPQUEUESTATS"."TANSWEREDACD", "IWRKGRPQUEUESTATS"."TTALKACD", "IWRKGRPQUEUESTATS"."CHKEY4", "IWRKGRPQUEUESTATS"."DINTERVALSTART", "IWRKGRPQUEUESTATS"."NHOLDACD", "IWRKGRPQUEUESTATS"."THOLDACD", "IWRKGRPQUEUESTATS"."NABANDONEDACD", "IWRKGRPQUEUESTATS"."NABANDONACDSVCLVL1", "IWRKGRPQUEUESTATS"."NABANDONACDSVCLVL2", "IWRKGRPQUEUESTATS"."NABANDONACDSVCLVL3", "IWRKGRPQUEUESTATS"."NABANDONACDSVCLVL4"
FROM "ADMIN"."IWRKGRPQUEUESTATS" "IWRKGRPQUEUESTATS"
WHERE "IWRKGRPQUEUESTATS"."CHKEY4"=N'*' AND "IWRKGRPQUEUESTATS"."CHKEY3"<>N'*' 
AND ("IWRKGRPQUEUESTATS"."CNAME">=N'ATEAM' 
AND "IWRKGRPQUEUESTATS"."CNAME"<=N'STORES') 
AND ("IWRKGRPQUEUESTATS"."DINTERVALSTART">={ts '2016-08-17 00:00:00'} 
AND "IWRKGRPQUEUESTATS"."DINTERVALSTART"<{ts '2016-08-17 23:59:59'})
ORDER BY "IWRKGRPQUEUESTATS"."CNAME";
4
  • Valid ANSI SQL syntax, excect {ts ...}. Commented Oct 7, 2016 at 13:33
  • Never seen curly brackets used like that before... Commented Oct 7, 2016 at 13:33
  • This looks wrong: WHERE "IWRKGRPQUEUESTATS"."CHKEY4"=N'*' Commented Oct 7, 2016 at 13:34
  • @DanBracuk: no, that's a valid SQL "nvarchar" literal (I think that is even part of the SQL standard - but at least Postgres, Oracle and SQL Server support that) Commented Oct 7, 2016 at 13:36

1 Answer 1

1

{ts '2016-08-17 23:59:59'} is an escape sequence for JDBC (and I think ODBC as well).

Those escape sequences are (have to be) converted by the client side (driver) to a proper syntax before the statement is sent to the server.

So whatever SQL client you are using it apparently doesn't support that (it's not using JDBC or ODBC)

Sign up to request clarification or add additional context in comments.

2 Comments

I am using Oracle SQL Developer if that helps. Should I change the "ts" to "to_date" and format that way?
@AWooster: Hmm, that's strange SQL Developer uses JDBC but it indeed complains for some reason (but I stopped trying to understand Oracle's decisions regarding their feature implementations). You might want to ask in Oracle's SQL Developer forum why that valid JDBC expression is rejected by SQL Developer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.