Java call stored procedure return parameters

zhaozj2021-02-16  72

Create Procedure [DBO]. [Sp_insertstudent] (@ Name Char (10), @ Age int, @ id int output) Asinsert Into Students ([Name], [AGE]) VALUES (@ Name, @ agn) select @ id = @@ identity - Test output parameter Return 30 - Test Returns 30GO

??? Try {????? pstmt = con.prepareCall ("{? = call sp_insertstudent (?,?,?)}"); ????? pstmt.setstring (2, "zengqingsong");? ???? pstmt.setint (3, 22);

????? pstmt.registeroutparameter (4, types.integer); ????? pstmt.registeroutparameter (1, types.integer); ????? int REGER); ????? int REGER); // Execute Row number

????? int RET2 = PSTMT.GETINT (1); // Return parameter (output parameter) ????? int ID = PSTMT.GETINT (4); // Output parameter ????? system.out .println (re); ????? system.out.println (RET2); ????? system.out.println (id); ???}

转载请注明原文地址:https://www.9cbs.com/read-15008.html

New Post(0)