Home » SQL & PL/SQL » SQL & PL/SQL » whats wrong with this?
whats wrong with this? [message #350939] Sat, 27 September 2008 21:49 Go to next message
soujanya_srk
Messages: 111
Registered: November 2006
Location: HYDERABAD
Senior Member

create or replace package pkg_dep 
as

	 procedure sel_dep;
	 procedure sel_dep1(p_id  number);
	 
end ;
/
	 
	 




create or replace package pkg_dep 
as

	 procedure sel_dep
	 is
         cursor mycur is select dno,dname from dept;
	 begin
	  for myrec in mycur loop
          insert into dept1 valules(myrec.dno,myrec.dname);
	  end loop;


	 end sel_dep;
	 procedure sel_dep1(p_id  number, p_out varchar2) is

	 begin
	 select dname into p_ouot from dept where dno=p_id;
	 end sel_dep1;
end ;
/
	 
	 


when i execute package body file, i get error

pls-00103 encountered CURSOR when expecting one of the
following: language

Re: whats wrong with this? [message #350946 is a reply to message #350939] Sun, 28 September 2008 00:48 Go to previous messageGo to next message
Michel Cadot
Messages: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
The latter one is a package BODY not a package.

Regards
Michel
Re: whats wrong with this? [message #351014 is a reply to message #350939] Mon, 29 September 2008 00:11 Go to previous messageGo to next message
chakradhar.adhikari
Messages: 5
Registered: September 2008
Junior Member
Hi

While you are creating package body you didnt specify the "body" keyword at starting that why you got error.

CREATE OR REPLACE PACKAGE SCOTT.pkg_dep
AS
PROCEDURE sel_dep;

PROCEDURE sel_dep1 (p_id NUMBER, p_out OUT varchar2);
END ;
/

CREATE OR REPLACE PACKAGE BODY scott.pkg_dep
AS
PROCEDURE sel_dep
AS
BEGIN
FOR myrec IN (SELECT deptno, dname
FROM dept1)
LOOP
INSERT INTO dept2
VALUES (myrec.deptno, myrec.dname);
END LOOP;
END sel_dep;

PROCEDURE sel_dep1 (p_id NUMBER, p_out OUT VARCHAR2)
AS
BEGIN
SELECT dname
INTO p_out
FROM dept1
WHERE deptno = p_id;
END sel_dep1;
END;
/
Re: whats wrong with this? [message #351023 is a reply to message #351014] Mon, 29 September 2008 01:03 Go to previous message
Michel Cadot
Messages: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
@chakradhar.adhikari

From your previous post:
Michel Cadot wrote on Tue, 23 September 2008 14:24
And you still don't follow the OraFAQ Forum Guide.


And your post does not add anything to what I posted.
FOLLOW guidelines.

Regards
Michel
Previous Topic: alter session set schema set schema_name
Next Topic: Decode Statement OR SubQuery
Goto Forum:
  


Current Time: Tue Feb 18 12:17:53 CST 2025