SELECT @@IDENTITY - sqljdbc driver

  • 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

  • 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?

  • 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"

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply