473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

problem while declaring a a cursor

1
The sql block is
=================
set pagesize 5000;
set serveroutput on
set linesize 200;
set heading off;
set feedback off;

DECLARE cursor1 CURSOR
FOR
SELECT element_id,element_type,name from NH_ELEMENT where name like '%DTH%';
end;
/
=====================
Error I get is :-
=====================
FOR
*
ERROR at line 2:
ORA-06550: line 2, column 1:
PLS-00103: Encountered the symbol "FOR" when expecting one of the following:
:= . ( @ % ; not null range default character
=====================

Can anyone figure out what's going wrong here?

Cheers,
Anu
Mar 14 '07 #1
2 1916
mivey4
37
The sql block is
=================
set pagesize 5000;
set serveroutput on
set linesize 200;
set heading off;
set feedback off;

DECLARE cursor1 CURSOR
FOR
SELECT element_id,element_type,name from NH_ELEMENT where name like '%DTH%';
end;
/
=====================
Error I get is :-
=====================
FOR
*
ERROR at line 2:
ORA-06550: line 2, column 1:
PLS-00103: Encountered the symbol "FOR" when expecting one of the following:
:= . ( @ % ; not null range default character
=====================

Can anyone figure out what's going wrong here?

Cheers,
Anu
Just curious why you are placing the / character at the end of your cursor body? My guess is that you are attempting to create the cursor based off the ORACLE format which won't work in MSSQL.

The proper model would be

DECLARE cursor1 CURSOR
FOR
Mar 14 '07 #2
mivey4
37
First you need to declare variables to store the returned content of the cursor, which is very different from a stored procedure. I will make some assumptions here to recreate your proposed cursor since I don't know your actual datatypes.

The proper Cursor model would be

Declare
@element_id int
,@element_type int
,@name varchar(20)

DECLARE cursor1 CURSOR
FOR
SELECT element_id,element_type,name from NH_ELEMENT where name
like '%DTH%';
OPEN cursor1
FETCH NEXT FROM cursor1 INTO
@element_id, @element_type, @name
WHILE (@@FETCH_STATUS = 0)
BEGIN
-- Do something with the variables here like:
print cast(@element_id as varchar(3))
END
CLOSE cursor1
DEALLOCATE cursor1
END

But I believe what you're actually trying to do is create a procedure, not a cursor. Cursors are typically discouraged unless absolutely necessary due to the overhead and a simple select statement certainly wouldn't merit the use of a cursor. Try using a procedure instead.


What database platform are you using? This forum is for SQL not ORACLE.
Mar 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: dinesh prasad | last post by:
I'm simply trying to divide each close1 column by 20, then insert that value into the twentydayMA field. The query keeps on running without finishing, even if I'm only using a single page of data....
0
by: Geoff Soper | last post by:
At http://geoffsoper.co.uk/mouseover/index4.htm I've coded some script which changes the cursor style when the mouse moves over two different map area tags (setting the cursor style directly for...
9
by: Chris Michael | last post by:
I am using the following class in a CSS document: ..loginsubmit { background-color: #ffffff; FONT-WEIGHT: bold; color: #002980; cursor: hand } It works perfectly well, but it won't validate...
1
by: teddysnips | last post by:
SQL Server 2000 I have a stored procedure that uses an extended SPROC to send an email notification to my customers when a document is distributed. However, the SPROC has an unexpected side...
4
by: Paul Thompson | last post by:
I am getting an odd, inscrutable error in Mozilla Firefox. When I use an array to shift focus to an element, I get the error Error: " nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" ...
3
by: Jim Luedtke | last post by:
Can someone help me understand what might be going wrong here? I'm writing a class template that looks something like this; /* myclass.h */ #include<vector> using namespace std template...
1
by: Riccardo Giomi | last post by:
Hi I would to display a Cursors.WaitCursor on a ListView control, so I tried listView.Cursor = Cursors.WaitCursor but it doesn't work at all, I see always the default cursor. The same thing...
8
by: flamexx7 | last post by:
Can anybody tell me what is wrong with declaration of pointer p ? template<class Tclass Stack { struct Link { T* data; Link* next; Link(T* dat, Link* nxt) : data(dat), next(nxt) {} }* head;...
3
by: jbeteta | last post by:
Hello, I have a problem declaring variables. I need to create an object oRpte as ReportClass on WebForm1.aspx and be able to use its value on WebForm2.aspx. For declaring the property oRpte()...
4
by: desktop | last post by:
When I try to compile this template: template <typename T> class ElementT<std::vector<T { public: typedef T Type; }; I get the error:
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.