I've seen in several examples where cursors are used particularly on
this board that people use
While @.@.FETCH_STATUS <> -1
BEGIN
IF @.@.FETCH_STATUS <> -2 BEGIN
..
END
END
On most of the Microsoft BOL examples I see that they seem to always
use...
WHILE @.@.FETCH_STATUS = 0
BEGIN
..
END
I have looked up the different meanings
"0 FETCH statement was successful.
-1 FETCH statement failed or the row was beyond the result set.
-2 Row fetched is missing."
http://msdn.microsoft.com/library/d... />
s_1c1f.asp
To get to the point, my question is why use one method over the other?
Is there some drawback to useing the "@.@.FETCH_STATUS = 0" method that
might not be apparent?
Do I need to worry about endless loops?
As you might surmise I have a UDF that is running much to long, and
when I look at the number of times my objects have been called, the
number is larger than it should be.Why? Consistency. Almost every fetch loop I've run across looks like this:
FETCH
WHILE @.@.FETCH_STATUS = 0
BEGIN
-- do something here
FETCH
END
When you or the poor slob who has to maintain your code looks at it six
months, one, or two years from now, it will be a lot easier to read if it
uses the above pattern.
<Contraptor@.gmail.com> wrote in message
news:1132634990.886050.150040@.g49g2000cwa.googlegroups.com...
> I've seen in several examples where cursors are used particularly on
> this board that people use
> While @.@.FETCH_STATUS <> -1
> BEGIN
> IF @.@.FETCH_STATUS <> -2 BEGIN
> ...
> END
> END
> On most of the Microsoft BOL examples I see that they seem to always
> use...
> WHILE @.@.FETCH_STATUS = 0
> BEGIN
> ...
> END
> I have looked up the different meanings
> "0 FETCH statement was successful.
> -1 FETCH statement failed or the row was beyond the result set.
> -2 Row fetched is missing."
> http://msdn.microsoft.com/library/d...>
als_1c1f.asp
> To get to the point, my question is why use one method over the other?
> Is there some drawback to useing the "@.@.FETCH_STATUS = 0" method that
> might not be apparent?
> Do I need to worry about endless loops?
> As you might surmise I have a UDF that is running much to long, and
> when I look at the number of times my objects have been called, the
> number is larger than it should be.
>|||Ok, so al long as I'm not doing anything to change the @.@.FETCH_STATUS
between when I FETCH and check for a valid @.@.FETCH_STATUS I have no
need to worry about infinite loops if using the
FETCH
WHILE @.@.FETCH_STATUS = 0
BEGIN
-- do something here
FETCH
END
method.
Now I just need to figure out why my UDF totally iced our test server
last night.
Showing posts with label ltgt. Show all posts
Showing posts with label ltgt. Show all posts
Tuesday, March 27, 2012
@@error can only capture limited error number?
Hi experts,
I'm quite
with the using of @.@.error in Microsoft SQL 2000. For
instance,
Select * From Table1
If @.@.error <> 0
print 'Got error!!!'
I can have the @.@.error to capture the error number 208 (Invalid object name
'Table1') if the specific table is not found inside database.
Any hint?Read http://www.sommarskog.se/error-handling-I.html and
http://www.sommarskog.se/error-handling-II.html
HTH,
Vinod Kumar
MCSE, DBA, MCAD, MCSD
http://www.extremeexperts.com
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp
"LBT" <LBT@.discussions.microsoft.com> wrote in message
news:A2937AFF-D8E6-4414-A148-5FAD803C75F5@.microsoft.com...
> Hi experts,
> I'm quite
with the using of @.@.error in Microsoft SQL 2000. For
> instance,
> Select * From Table1
> If @.@.error <> 0
> print 'Got error!!!'
> I can have the @.@.error to capture the error number 208 (Invalid object
name
> 'Table1') if the specific table is not found inside database.
> Any hint?
I'm quite
instance,
Select * From Table1
If @.@.error <> 0
print 'Got error!!!'
I can have the @.@.error to capture the error number 208 (Invalid object name
'Table1') if the specific table is not found inside database.
Any hint?Read http://www.sommarskog.se/error-handling-I.html and
http://www.sommarskog.se/error-handling-II.html
HTH,
Vinod Kumar
MCSE, DBA, MCAD, MCSD
http://www.extremeexperts.com
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp
"LBT" <LBT@.discussions.microsoft.com> wrote in message
news:A2937AFF-D8E6-4414-A148-5FAD803C75F5@.microsoft.com...
> Hi experts,
> I'm quite
> instance,
> Select * From Table1
> If @.@.error <> 0
> print 'Got error!!!'
> I can have the @.@.error to capture the error number 208 (Invalid object
name
> 'Table1') if the specific table is not found inside database.
> Any hint?
Sunday, March 25, 2012
Data transfer Pocket PC <> Desktop PC?
Hi,everyone!
I'm new to this forum and also new to Visual Studio 2005 .NET.
I'm going to develop a pocket pc(windows mobile 2005) application which needs to save some data introduced by the user.Later that data should be syncronized with MS SQL Server database.
The application is going to be developed using Visual Studio 2005 with c#.
So I'm doubting wich is the best way of syncronising the data between Pocket Pc and a Desktop PC.Should i use MS SQL Server Mobile(RDA,Merge Replication) or XML(Xml Web Services) would help me better?Or is there any other better way of data syncronization/storage?
Could anyone help me,or post some links + code samples,please?
Thanks!
You'll need to provide more information ... how much data? What sort of data? Will it need to be wrapped in a transaction and/or have other potential for rollback? How critical is it/how reliable does the synchronization need to be? Have you looked into the Service Broker? (I'm exploring this for a project myself.)
Subscribe to:
Posts (Atom)