Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1184
  • Last Modified:

Insert rows through a cursor

Hi,

As a newbie on Sybase, I try to insert data in a table using a cursor as follows within a window in SQL Advantage :
DECLARE group_name_cur FOR SELECT DISTINCT group_name FROM DECLARE group_name_cur CURSOR FOR SELECT DISTINCT group_name FROM GROUP_AMOUNT
FOR READ ONLY
GO

DECLARE @grp_name char(30)

OPEN group_name_cur
FETCH group_name_cur INTO @grp_name

WHILE (@@sqlstatus = 0)
BEGIN
     INSERT INTO GROUP_AMOUNT VALUES (@grp_name, 3, -1, 0)
     INSERT INTO GROUP_AMOUNT VALUES (@grp_name, 3, -1, 1)

     FETCH group_name_cur INTO @grp_name
END

CLOSE group_name_cur
DEALLOCATE group_name_cur
GO

It raised the issue :

Server 'DEV9_DS', Line 15:
Incorrect syntax near 'group_name_cur'.

Any ideas ???
0
Richard Coffre
Asked:
Richard Coffre
  • 2
  • 2
1 Solution
 
ahoorCommented:
It's DEALLOCATE CURSOR group_name_cur
so just the word cursor

I suppose you copied your declare wrong?

Arjan
0
 
Richard Coffree-commerce Product ManagerAuthor Commented:
Thanks It solved my issue but then I found a misprint in the book where I found a example : "Sybase SQL Server 11 Unleashed, p 162".
0
 
Richard Coffree-commerce Product ManagerAuthor Commented:
One more thing don't care of the misprint at the beginnig of my question within the declaration of the cursor.
In fact, with the correct declaration I still had the issue described.
0
 
ahoorCommented:
You're right about the Unleashed... strange
The declare part I alreadythought you had copied something double.
Anyway, glad I could help... thanks.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now