Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> how to create cursor

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: how to create cursor
 Neeraj  Posted: Jun 20, 2008 06:24:15 AM

 Total Post: 254
 Joined: Jan, 2007






 hi,
i want to create a cursor w/ multiple column so how to create it & how to fetch that values.
cursor ci is
select empno,empname from emp;
thxs

 newuser
Posted: Jun 20, 2008 11:27:58 AM  

 Total Post: 6
 Joined: Feb, 2008






 
hi,
hope this will help ... i created to fetch 2 column for a single row only

declare
e_empname varchar2(20);
e_empid number(5);
cursor c1 is
select empname,empid from emp;
begin
open c1;
fetch c1 into e_empname,empid;
dbms_output.put_line(e_empname||e_empid);
close c1;
end;

 Neeraj
Posted: Jun 21, 2008 01:49:07 AM  

 Total Post: 254
 Joined: Jan, 2007






 
thxs frd,
can u tell me how to update empid of every empname with another empid in another table.i want to update empid of emp table w/ empid of emp1 table but like set emp.empno=emp.empno-emp1.empno

declare
e_empname varchar2(20);
e_empid number(5);
cursor c1 is
select empname,empid from emp;
begin
open c1;
fetch c1 into e_empname,empid;
dbms_output.put_line(e_empname||e_empid);
close c1;
end;


thxs again

 Vish
Posted: Jul 27, 2008 08:15:48 AM  

 Total Post: 50
 Joined: Jan, 2007






 
you can use for loop

like this

for c1 in c1_rec loop
...
....
.....
end for

in for loop u didn't have to do loop and u didnt have to open cursor and fetch and exit, it will take care by for loop


 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar856
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Gitesh Trivedi322
  Gopu Gopi281
  neeraj sharma254
  Ramesh Jois245
  Bishal Khetan207






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software