Home » SQL & PL/SQL » SQL & PL/SQL » pl/sql learner
pl/sql learner [message #250938] Wed, 11 July 2007 22:28 Go to next message
Neeharika
Messages: 6
Registered: July 2007
Location: JAPAN
Junior Member

Hi All,
i created function and i want to call inpl/sql am getting error.plz help me.



create or replace function classinfo(p_department classes.deparartment%type,
p_course classes.course%type)return varchar2 is
v_current_students number;
v_max_students number;
v_fullpercent number;
begin
select current_students,max_students into v_current_students,v_max_students from
classes
where deparartment=p_department
and course=p_course;
v_fullpercent:=v_current_students/v_max_students*100;
if v_fullpercent=80 then
return 'full';
else
return'empty';
end if;
end classinfo;




cll in pl/sql

SQL> declare
2 cursor c_class is select deparartment,course from classes
3 ;
4 begin
5 for v_class in c_class loop
6 if classinfo(v_class.deparartment,v_class.course) then
7 dbms_output.put_line('full');
8 else
9 dbms_output.put_line('not full');
10 end if;
11 end loop;
12 end;
13 /
if classinfo(v_class.deparartment,v_class.course) then
*
ERROR at line 6:
ORA-06550: line 6, column 4:
PLS-00382: expression is of wrong type
ORA-06550: line 6, column 1:
PL/SQL: Statement ignored
Re: pl/sql learner [message #250940 is a reply to message #250938] Wed, 11 July 2007 22:43 Go to previous messageGo to next message
BlackSwan
Messages: 25039
Registered: January 2009
Location: SoCal
Senior Member
Is the following valid PL/SQl?
if 'full' then
   dbms_output.put_line('full');
else
   dbms_output.put_line('not full');
end if;

[Updated on: Wed, 11 July 2007 23:08] by Moderator

Report message to a moderator

Re: pl/sql learner [message #250941 is a reply to message #250938] Wed, 11 July 2007 23:03 Go to previous messageGo to next message
Neeharika
Messages: 6
Registered: July 2007
Location: JAPAN
Junior Member

i cant understand.

Thanks.
Appaji.
Re: pl/sql learner [message #250943 is a reply to message #250938] Wed, 11 July 2007 23:10 Go to previous messageGo to next message
BlackSwan
Messages: 25039
Registered: January 2009
Location: SoCal
Senior Member
I posted how the PL/SQL compiler views your IF statement.
Simply put, your IF statement is malformed & invalid syntax.
Re: pl/sql learner [message #250948 is a reply to message #250943] Wed, 11 July 2007 23:43 Go to previous messageGo to next message
Neeharika
Messages: 6
Registered: July 2007
Location: JAPAN
Junior Member

yes i got.

Thanks.
Appaji.


1 declare
2 cursor c1 is select deparartment,course from classes;
3 r varchar2(200);
4 begin
5 for i in c1 loop
6 r:= classinfo(i.deparartment,i.course);
7 dbms_output.put_line(r);
8 /*else
9 dbms_output.put_line('not full');
10 end if;*/
11 end loop;
12* end;
SQL> /

PL/SQL procedure successfully completed.

SQL> set serveroutput on;
SQL> /
full
empty
empty
full
Re: pl/sql learner [message #250969 is a reply to message #250948] Thu, 12 July 2007 01:45 Go to previous message
Michel Cadot
Messages: 64119
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please read and follow How to format your posts and How to get a quick answer to your question: TIPS AND TRICKS
Make sure that lines of code do not exceed 80 or 100 characters when you format.
Please always post your Oracle version (4 decimals).

Regards
Michel
Previous Topic: problem on associative array
Next Topic: Function/Procedure that returns total sum
Goto Forum:
  


Current Time: Tue Dec 06 08:23:16 CST 2016

Total time taken to generate the page: 0.05916 seconds