Solved

Insert rows through a cursor

Posted on 2001-07-09
4
1,122 Views
Last Modified: 2010-05-18
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
Comment
Question by:Richard Coffre
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
ahoor earned 50 total points
ID: 6265591
It's DEALLOCATE CURSOR group_name_cur
so just the word cursor

I suppose you copied your declare wrong?

Arjan
0
 
LVL 1

Author Comment

by:Richard Coffre
ID: 6267948
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
 
LVL 1

Author Comment

by:Richard Coffre
ID: 6267956
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
 
LVL 3

Expert Comment

by:ahoor
ID: 6268283
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Copy a TadoDataSet to another and apply changes to database. 11 1,252
SQL Query Syntax 11 160
MS SQL Linked server 3 125
set dsync and directio options according to device type 4 38
We need a new way to communicate time sensitive or critical info.   The best part of my role at xMatters is visiting our clients all over the world to learn about how they operate their businesses, share insights that xMatters has gleaned across…
In 2017, ransomware will become so virulent and widespread that if you aren’t a victim yourself, you will know someone who is.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now