Skip to Content.
Sympa Menu

freetds - RE: [freetds] Testing for query success

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] Testing for query success
  • Date: Wed, 12 Jan 2005 11:14:20 -0000

Jim,

Shortish answer:

in SQL Server there are a number of types of error condition.
Some will terminate a whole batch, whereas others will terminate a
statement within a batch (or a statement within a stored procedure for
that matter)
Judging by the text of the error message This error falls into the
latter case.
In this latter case, within a stored procedure, it's up to you to trap
errors and adjust the logic accordingly.

You might for example code the following after each statement of a
stored procedure:

if @@error <> 0
begin
return -1
end

If you choose not to trap errors like this, the stored procedure will
continue executing.

The error message is being returned by freetds, because the server
pushes any error message generated in the course of a batch execution
back to the client.
Most client applications then print these out using an "error handler" -
sqsh certainly does this.
But neither freetds or sqsh (which then handles the message by printing
it out) use the presence of a message to "flag" an error in any way.

Bill

P.S. The underlying cause of the error message is likely to be more
complicated.


-----Original Message-----
From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of James Vanns
Sent: 12 January 2005 11:03
To: FreeTDS Development Group
Subject: [freetds] Testing for query success


Dear all,

First a happy new year to you. Now, to the point! I am issuing an UPDATE
statement (actually I am calling a stored procedure that issues this
statement) against a Microsoft SQL Server (2000).

I am testing this using sqsh also...

Basically, this SP succeeds yet I also get an error message returned
(not a record set):

'Arithmetic overflow error converting expression to data type
datetime.The statement has been terminated.'

As I said - the update succeeds and the date format is accepted and
stored fine (format was: 2003-04-11 17:29:27).

So

a) Why is this message returned by FreeTDS?
b) If this error message is returned how come the SQSH (and therefore
FreeTDS?) program prints '(return status = 0)' also? Doesn't 0 signify
success?

Any direction you can give me to the solution to this will be
appreciated. I.e. what dblib or even tds functions should I be calling
to test for the real success or failure of my statement?

Regards

Jim Vanns

PS: This is FreeTDS 0.62

--
James Vanns BSc (Hons) MCP
Linux Systems Administrator
Software Engineer (Linux / C & C++)
Canterbury Christ Church University College
Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x24045370


_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
--------------------------------------------------------

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