Home » Other » Training & Certification » pl/sql program to copy
icon5.gif  pl/sql program to copy [message #322090] Thu, 22 May 2008 08:27 Go to next message
amritaseema
Messages: 47
Registered: January 2008
Member
Hi All...
i need some help....
here i tried to write a pl/sql program to copy all emp table records whose salary is greater than 2000 to another table
can you please check the code...
its showing error...

ORA-01422: exact fetch returns more than requested number of rows


actually i knew this error is showing beacue of the into
but i am unable to resolve it....
can you please help me out...

DECLARE
   v_sal      employees.salary%TYPE;
   v_emprec   employees%ROWTYPE;
BEGIN
   SELECT *
     INTO v_emprec
     FROM employees;

   IF v_sal > 2000
   THEN
      INSERT INTO employees_copy
         SELECT *
           FROM employees
          WHERE salary > 2000;
   END IF;
END;


thanks in advance
Seema

[Updated on: Thu, 22 May 2008 08:27]

Report message to a moderator

Re: pl/sql program to copy [message #322100 is a reply to message #322090] Thu, 22 May 2008 08:59 Go to previous messageGo to next message
BlackSwan
Messages: 22546
Registered: January 2009
Senior Member
1) do not do in PL/SQL what can be done using only SQL.
2) how do you place multiple rows INTO a single variable?
Re: pl/sql program to copy [message #322101 is a reply to message #322100] Thu, 22 May 2008 09:01 Go to previous messageGo to next message
amritaseema
Messages: 47
Registered: January 2008
Member
but i need it in pl/sql only....
please help me out...
yeah i know error is there only in the into...
but unable resolve it....
please help me..
Re: pl/sql program to copy [message #322110 is a reply to message #322101] Thu, 22 May 2008 09:23 Go to previous message
Michel Cadot
Messages: 58635
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
PL/SQL User's Guide and Reference
Chapter 6 Performing SQL Operations from PL/SQL
Section Managing Cursors in PL/SQL

Regards
Michel

Previous Topic: Index Table
Next Topic: days between last month
Goto Forum:
  


Current Time: Thu Jul 31 13:52:37 CDT 2014

Total time taken to generate the page: 0.14248 seconds