D
D
DunkanMaklaut2020-07-20 08:24:07
Java
DunkanMaklaut, 2020-07-20 08:24:07

The statement did not return a result set. What's wrong with the request?

In MS SQL studio it works as it should, but in Java code an exception is thrown: "The statement did not return a result set"

String sql=
                "DECLARE @rsrc_izm TABLE (rsrc_id INT,rsrc_name VARCHAR(max))
  INSERT INTO @rsrc_izm
 SELECT rsrc_id,rsrc_name FROM RSRC WHERE rsrc_id=(SELECT rsrc_id FROM exec_team AS et WHERE id = ?)  ORDER BY   CASE
   when rsrc_id=(SELECT rsrc_id FROM exec_team AS et WHERE id = ?)
   THEN '1'
   ELSE '2'
 END,rsrc_short_name
 
  INSERT INTO @rsrc_izm
   SELECT rsrc_id,rsrc_name FROM RSRC WHERE timesheet_flag='Y' AND active_flag='Y'  
 
 SELECT rsrc_id,rsrc_name FROM @rsrc_izm
 ORDER BY   CASE
   when rsrc_id=(SELECT rsrc_id FROM exec_team AS et WHERE id = ?)
   THEN '1'
   ELSE '2'
                END";
PreparedStatement preparedStatement = connection.prepareStatement(sql);
                    preparedStatement.setInt(1,id);
                    preparedStatement.setInt(2,id);
preparedStatement.setInt(3,id);
                    ResultSet resultSet = preparedStatement.executeQuery(); //throwables: com.microsoft.sqlserver.jdbc.SQLServerException: Инструкция не вернула результирующий набор.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2020-07-20
@tsklab

SELECT 1, rsrc_id, rsrc_name FROM RSRC WHERE rsrc_id=?
UNION
SELECT 2, rsrc_id, rsrc_name FROM RSRC WHERE timesheet_flag = 'Y' AND active_flag = 'Y'
ORDER BY 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question