Skip to Content.
Sympa Menu

freetds - Re: [freetds] SELECT @@IDENTITY AS InsertID

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: <s.craig AT andronics.com>, "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] SELECT @@IDENTITY AS InsertID
  • Date: Thu, 6 Oct 2005 11:56:18 -0400

> From: Shaun Craig
> Sent: Thursday, October 06, 2005 11:37 AM
>
> I break the query string up depending on how many statements are in
it,
> so for above i have 2, 1 for insert and 1 for select
>
> for ( x = 0; x < amount of statments + 1; x++ )
> {
> //first time around it will be the insert which inserts ok
> dbcmd(dbconn, statements[x])
> dbsqlexec(dbconn)
> dbresults(dbconn)
>
> if we find that the statement is a 'Select @@Identity..etc' we go
in
> here, we wont the first time but when we go around the second time we
> will go in.
> {
> // try bind select to variable
> dbbind(dbconn, 1, INTBIND, (DBINT)0, (BYTE *)& InsertID);
//its
> says its binding ok but what its binding i cant be sure!
>
> if (dbnextrow(dbconn) != NO_MORE_ROWS)
> journey_insert_id = InsertID;
> }
> }

In addition to Bill's advice, make sure you're checking the return code
from each db-lib call. And you might want to do some sanity checks with
dbcoltype(), dbnumcols(), dbcolname() to make sure the column you're
binding to is really the one you're expecting.

BTW, re the pool server, I don't have anything for you. Someone more
familiar with the code (and/or more motivated) would need to look at it.


HTH.

--jkl

-----------------------------------------
The information contained in this transmission may be privileged and
confidential and is intended only for the use of the person(s) named
above. If you are not the intended recipient, or an employee or agent
responsible
for delivering this message to the intended recipient, any review,
dissemination,
distribution or duplication of this communication is strictly prohibited. If
you are
not the intended recipient, please contact the sender immediately by reply
e-mail
and destroy all copies of the original message. Please note that we do not
accept
account orders and/or instructions by e-mail, and therefore will not be
responsible
for carrying out such orders and/or instructions. If you, as the intended
recipient
of this message, the purpose of which is to inform and update our clients,
prospects
and consultants of developments relating to our services and products, would
not
like to receive further e-mail correspondence from the sender, please "reply"
to the
sender indicating your wishes. In the U.S.: 1345 Avenue of the Americas, New
York,
NY 10105.




Archive powered by MHonArc 2.6.24.

Top of Page