Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SELECT @@IDENTITY - sqljdbc driver Expand / Collapse
Author
Message
Posted Tuesday, September 15, 2009 5:19 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, September 17, 2009 8:34 AM
Points: 1, Visits: 8
Hi!

We are porting a database from SQL Server 2000 to SQL Server 2008 and server is Weblogic server 8.1 SP6. Earlier for SQl 2000 we used jdriver and now we upgraded to sqljdbc 1.2 driver. We have problems with insert staments followed by an SELECT @@IDENTITY. SQLException has raised The statement did not return a result set.
We are using prepared statement.
Please give me suggestions to resolve this issue.

Thanks in advance
Allu
Post #788067
Posted Tuesday, September 15, 2009 6:53 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:53 PM
Points: 7,105, Visits: 15,442
Switch to using the OUTPUT clause instead. It WILL be a single statement and won't have the vulnerabilities that @@identity has.

Insert MyTable(Mycolumns)
Output inserted.MyIdentity
select MyColumnValue



----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Post #788104
Posted Thursday, September 17, 2009 4:05 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, September 23, 2014 8:08 AM
Points: 2,365, Visits: 1,846
select @@identity returns last inserted value of the current session. I think your prepared statement is run in one session and the select @@identity in another.

"Keep Trying"
Post #789511
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse