in reply to Re: Re: Re: Getting identity after autoincr in FreeTDS/MSSQL/DBI
in thread Getting identity after autoincr in FreeTDS/MSSQL/DBI

If the value for @@identity is empty when doing this as two requests it means that the select @@identity is done on a different physical connection from the insert. This usually happens when you don't completely flush all the results after the initial insert.

I'm thinking of adding an attribute to DBD::Sybase that would inhibit the automatic secondary connections to handle multiple concurrent $sth on a single database handle as that causes quite a lot of confusion for people...

Michael

  • Comment on Re: Re: Re: Re: Getting identity after autoincr in FreeTDS/MSSQL/DBI
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Getting identity after autoincr in FreeTDS/MSSQL/DBI
by berntsmr (Novice) on Jan 03, 2003 at 21:21 UTC
    Since you are using two commands off one prepare, you may need to
    use the:

    while ( $someVar = $sth->fetch ) { do ( something... ) while ( $sth->{syb_more_results} );

    syntax.

    This is explained in the "Programming the Perl DBI" book
    PG: 326 Don't know if it helps - but it's worth a try.