Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

returning @@identity from a sql server stored proc to a java program

Status
Not open for further replies.

eja2000

Programmer
Nov 30, 2003
209
NG
can u show me how to put the @@IDENTITY value of a insert stored proc (sql server 2000) into a variable in java?
thx
 
This approach should work:
1.) Return @@IDENTITY from your stored proc.
...RETURN @@IDENTITY
2.) Declare a CallableStatement: "{? = call your_sp(?)}"
3.) Register Out parameter: cs.RegisterOutParameter(1, Types.INTEGER);
4.) Set parameters: cs.setString(2,"test");
4.) Call sp: cs.executeUpdate();
5.) get value: cs.getInt(1);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top