简体   繁体   中英

MSSQL 2005 - JDBC4 and subqueries

I tried a query which

  • A) fills var table
  • B) gets the var table data as helpful to select next data
 CREATE PROCEDURE Test AS BEGIN DECLARE @A TABLE ( id INT NOT NULL, name VARCHAR(50) ); INSERT @A SELECT id,name FROM table1 WHERE id>10 DECLARE @B TABLE ( address VARCHAR(255), city VARCHAR(128) ); INSERT @b SELECT address,city FROM table2 WHERE id IN(SELECT id FROM @A) END; 

... so, as a result, I have two select statements in my procedure :S The thing is... All procedures which contain just one select statement behave fine with JDBC4 but here something is wrong because when procedure contains two select statement it returns nothing :( So my question can two select statement cause the problem with jdbc4? A if it does how to fix it?

Try adding SET NOCOUNT ON (edit: once at the top of the procedure body) to the stored procedure. The result of this is sent back and may be confusing JDBC 4: this is quite common...

See SET NOCOUNT ON usage for more

CREATE PROCEDURE  Test
AS
BEGIN
SET NOCOUNT ON; -- here

DECLARE @A TABLE
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM