Skip to Content.
Sympa Menu

freetds - Re: [freetds] a question about transaction

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <bill_d_thompson AT ml.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] a question about transaction
  • Date: Mon, 13 Feb 2006 13:16:01 -0000

Hi,

You say you have a "strange instance" where "no code is returned"...

from where is "no code returned" ? from ct_results ? or from your
run_command() function ?

what return code are you trying to capture ?
is it the successful completion of all the commands you have submitted ?

I would capture and print out all the returns from ct_results, which should
help to make it clearer.

I would say, as long as you never get CS_CMD_FAIL returned from ct_results()
your commands have worked.

By the way, I think you should implement the addnewcarduser functionality as
a stored procedure, into which you pass username, password and userip
(maybe current date too, although the stored proc could work that out for
you.)


Bill





-----Original Message-----
From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of lichunlei AT kingsoft.com
Sent: 13 February 2006 12:24
To: freetds-request AT lists.ibiblio.org
Cc: freetds AT lists.ibiblio.org
Subject: [freetds] a question about transaction


hi:

i am writing a programme which execute a transaction by freetds , however
, there is a strange instance that no code is returned ,but the sqlserver
data had been influenced . i need the returnd code to execute the next
step. but nothing.


i use the function run_command which is programmed by myself to execute sql
sentence which have no returned result.


function:


/* Run commands from which we expect no results returned */
// Update,insert,delete
static inline CS_RETCODE run_command(CS_COMMAND * cmd, const char *sql )
{
CS_RETCODE ret, results_ret;
CS_INT result_type;

if (cmd == NULL) return CS_FAIL;
if (ct_command(cmd, CS_LANG_CMD, sql, CS_NULLTERM, CS_UNUSED) != CS_SUCCEED)
return CS_FAIL;
if (ct_send(cmd) != CS_SUCCEED) return CS_FAIL;

while ( (results_ret = ct_results( cmd , &result_type ) ) == CS_SUCCEED )
{
switch ((int) result_type)
{
case CS_CMD_SUCCEED:
break;
case CS_CMD_DONE:
break;
case CS_CMD_FAIL:
return E_NORMAL;
default:
return CS_FAIL;
}
}
switch ( (int) results_ret )
{
case CS_END_RESULTS:
break;
case CS_FAIL:
default:
return CS_FAIL;
}

return CS_SUCCEED;
}


the transaction is :
snprintf( szInsert,
SQL_BUFFER_LENGTH,
"BEGIN TRANSACTION addnewcarduser "
"Insert into authinfo2( uid,password) values( \'%s\',\'%s\')"
"Insert into secuinfo( uid,password2) values( \'%s\',\'%s\')"
"insert into statinfo(uid,reg_date,reg_ip) values( \'%s\',\'%s\' ,%d)"
"insert into last_login(uid,last_login_time,last_login_ip) values(
\'%s\',\'%s\',%d)"
"insert into userinfo(uid) values( \'%s\')"
"insert into money(uid) values( \'%s\')"
"insert into point(uid) values( \'%s\')"
"update secuinfo set user_type=user_type+power(2,2)
,service=service+power(2,3) where uid = \'%s\'"
"insert into op_log(uid,op_type,op_time,op_detail,op_ip) values(
\'%s\',11,\'%s\','新手卡激活:成功',%d)"
"COMMIT TRANSACTION addnewcarduser",
val->username ,
val->password ,
val->username ,
val->password ,
val->username ,
ChangeTmFormat(val->currentdate,szTime) ,
val->userip ,
val->username ,
ChangeTmFormat(val->currentdate,szTime) ,
val->userip ,
val->username ,
val->username ,
val->username ,
val->username ,
val->username ,
ChangeTmFormat(val->currentdate,szTime) ,
val->userip );


please tell me how to get the return code .
--------------------------------------------------------

If you are not an intended recipient of this e-mail, please notify the
sender, delete it and do not read, act upon, print, disclose, copy, retain or
redistribute it. Click here for important additional terms relating to this
e-mail. http://www.ml.com/email_terms/
--------------------------------------------------------




Archive powered by MHonArc 2.6.24.

Top of Page