Written by

Lead Technical Analyst at Missouri Health Connection
Question Scott Beeson · Nov 18, 2016

How to declare TSQL variable over JDBC connection?

I'm trying to use the standard TSQL DECLARE syntax but I get the following error:

[%msg: < IDENTIFIER expected, @ found^  DECLARE @>]

How do I declare a variable?  For instance:

DECLARE @numrecords int = 10;
SELECT TOP @numrecords FROM mytable;

Comments

Dmitry Maslennikov · Nov 18, 2016

We can use TSQL from Caché side, with changing dialect to MSSQL, and this statement will work. But not sure how it would be possible with JDBC.

0
Scott Beeson  Nov 21, 2016 to Dmitry Maslennikov

Why is it different?  This is very inconvenient :(

0
Dmitry Maslennikov  Nov 22, 2016 to Scott Beeson

JDBC doesn't have any directives in this case, but I think if you ask InterSystems via WRC, about this feature, they may  add it in new versions.

0