jsp jstl sql 使用声明的变量查询标签?

jsp jstl sql query tag using declared variables?

在 jstl 中使用 "SET @" 任何内容时遇到问题。有什么技巧可以让它发挥作用吗?

<sql:query var="weektots" dataSource="jdbc/x" >
SET @tot:=0;
SELECT
 (@tot := @tot + 5) AS rt
<sql:query>

其他无效的尝试:

<sql:transaction dataSource="jdbc/x">
<sql:query var="weektots" >
    SET @tot:=0;
 <sql:query>
 <sql:query var="weektots" dataSource="jdbc/x" >
       SELECT
     (@tot := @tot + 5) AS rt
    <sql:query>
  </sql:transaction>

  <c:set var="tot" value="0" />
  <sql:query var="weektots" dataSource="jdbc/x">
       SELECT
     (${tot} := ${tot} + 5) AS rt
  <sql:query>

有什么方法可以实现吗?

最终创建了一个存储过程以在 JSTL 中执行此操作。

    DELIMITER $$
 CREATE PROCEDURE w10rt()
   BEGIN
    SET @tot:=0;
    SELECT
     (@tot := @tot + 5) AS rt
   END $$
 DELIMITER ; 

在 jsp 内使用 "Call w10rt" 得到正确的结果。

  Call w10rt