473,425 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,425 developers and data experts.

PL/SQL-CURSOR - 1

debasisdas
8,127 Expert 4TB
This thread contains some useful tips/samples regarding cursors, that the forum members may find useful.

Cursor
===========
Implicit Cursor--sql Returns Single Line. Created By Oracle Server.
Explicit Cursor--sql Retuns Multiple Line Of Record. Created By User.
----------
Cursor Life Cycle
----------
Declare-->open-->fetch-->check Last Record-->close

Basic Syntax
---------------------------
Expand|Select|Wrap|Line Numbers
  1. Declare
  2. Cursor Cursorname [(param1,param2,....)]
  3. Is Select Statment [for Update [of Col1,col2,..];
  4. Begin
  5. Open Cursorname[(input Arguments)];
  6. Loop
  7. Fetch Cursorname Into V1,v2,.....;
  8. End Loop;
  9. Close Cursorname;
  10. End;
  11.  
----CURSOR ATTRIBUTES---

%FOUND---returns--BOOLEAN
%NOTFOUND--returns---BOOLEAN
%ISOPEN--returns---BOOLEAN
%ROWCOUNT---returns---INTEGER
%BULKROWCOUNT----returns-----INTEGER

Sample test code for cursor.
=======================
Expand|Select|Wrap|Line Numbers
  1. DECLARE
  2. I EMP.EMPNO%TYPE;
  3. J EMP.ENAME%TYPE;
  4. CURSOR C IS SELECT EMPNO,ENAME FROM EMP;
  5. BEGIN
  6. OPEN C;
  7. LOOP
  8. FETCH C INTO I,J;
  9. DBMS_OUTPUT.PUT_LINE(I||'       '||J);
  10. EXIT WHEN C%NOTFOUND;
  11. END LOOP;
  12. CLOSE C;
  13. END;
  14.  

Please try on SCOTT Schema


Also check PL/SQL-CURSOR - 2
May 28 '07 #1
0 4148

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

Similar topics

3
by: cooldv | last post by:
i am running a website on Windows 2000 server with ASP 3 webpages and Access 2000 database. (with a hosting company) traffic is slow at this time but expect to grow. lately i have been reading...
2
by: Peter | last post by:
I run most of my SQL scripts via kornshell on AIX. I use the "here-document" to run some of the smaller ones. Example: #!/bin/ksh # Analyze the table. sqlplus...
10
by: Dagwood | last post by:
Good morning: At least it's morning where I am. :) I have a rather newbie question I'm afraid. I have VisualStudio.NET, and have installed it along with SQL server. However I can't seem to...
2
by: Ken Lindner | last post by:
I have a need to become familiar with SQL Server 2000 for work. Needless to say I am new to SQL Server any version, but not IT in general. My employer has provided me with the SQL Server 2000...
6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
4
by: coosa | last post by:
Hi, I was installing SQL Server on my machine and during installation my PC freezed. It happens frequently on my machine. So i tried after restarting to install it again and since then i always...
1
by: Peter | last post by:
I've purchased VS.NET 2005 Standard and have tried to install SQL Server 2005 Express, but get the following error in the error log. Please could someone help me.... Microsoft SQL Server 2005...
6
by: Fuzzydave | last post by:
I am back developing futher our Python/CGI based web application run by a Postgres DB and as per usual I am having some issues. It Involves a lot of Legacy code. All the actual SQL Querys are...
14
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can...
5
by: dbrother | last post by:
Access 2003 Win XP Pro SP3 Using SQL /ADO Recordsets in a Do Loop Hello, I'm using a random number generator based on an integer input from a user from a form that will get X number of random...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.