Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Insert rows through a cursor

Posted on 2001-07-09
4
Medium Priority
?
1,177 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
ahoor earned 200 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

While opting for any web-to-print solution, you need to discuss with your team and some of your end users and know their opinions about your decisions. In this article we list down some questions you need to ask yourself.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

704 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