FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Strange SQL cursor problem. Pls do not ignore if can help.

 


shamil
I have table called material_info with below create code.
Code:
CREATE TABLE [dbo].[material_info](
   [material_info_id] [int] IDENTITY(1,1) NOT NULL,
   [material_id] [int] NULL,
   [amount_type_id] [int] NULL,
   [mat_kod] [varchar](4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_material_info] PRIMARY KEY CLUSTERED
(
   [material_info_id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO

I use a cursor in stored proc which declared as
Code:
declare mycurs cursor LOCAL  for select mat_kod from material_info order by mat_kod;

Code:
OPEN mycurs   
FETCH NEXT FROM mycurs INTO @mycurKod 
--FETCH NEXT FROM mycurs INTO @mycurKod
WHILE @@FETCH_STATUS = 0
BEGIN
   insert into my values(@mycurKod)
   /* my code */
   FETCH NEXT FROM mycurs INTO @mycurKod
END


Problem is that the first fetch doesn't work it returns null so i have to use double fetch before going into loop. I tried cursor sql independently to see if there is null value but there isin't.
But whenever i take off order by clause it works. But i need order by also. Why this happens?
I will really appreciate your help.
albuferque
Try to change FORWARD_ONLY setting of the cursor

http://www.teratrax.com/articles/sql_server_cursor.html

Hope that helps.
shamil
Thanks for your reply.
It has been already solved. Problem was i inserted null into table and executed cursor before updating null to new value;
Related topics

Strange Fire fox problem
Seriously strange Phpbb forum problem
Webpage Display Problem
Strange DSL modem problem
Serious Problem

windows amazing problem OR computer hardware problem
Strange SQL error
domain
LAN is one-way & takes a click to be two-way. Why?
SQL query problem

Am i being too jealous ?
Firefox Search Engine Bar
Internal Server Error
Form Mail help........lol
Strange flash intro problem
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.