Question:
Why is Oracle throwing a fit with this PL/SQL program?
anonymous
2006-09-27 14:42:57 UTC
create or replace procedure complaint_details(rental_no_in IN number) IS

cursor complaint_cursor is
select rental_date
from rental
where rental.rental_no = rental_no_in;
cursor_row complaint_cursor%rowtype;
v_tenant_name varchar2(30) := '';
c_count number(2) := 0;
v_tenant_name := tenant_function(rental_no_in);
c_count := complaints_qty(rental_no_in);

begin
for complaint_row in complaint_cursor
loop
dmbs_output.put_line(v_tenant_name||' '||complaint_row.rental_date||
' '||c_count);
end loop;
end;

Here is the error message that Oracle throws right at me.
ERROR at line 10: PLS-00103: Encountered the symbol "=" when expecting one of the following:

constant exception
table LONG_ double ref
char time timestamp interval date binary national character
nchar
The symbol "" was substituted for "=" to continue.
1. create or replace procedure complaint_details(rental_no_in IN number) IS
2.
3. cursor complaint_cursor is
Three answers:
pauloplanez
2006-09-28 17:36:07 UTC
create or replace procedure complaint_details(rental_no_in IN number) IS



cursor complaint_cursor is

select rental_date

from rental

where rental.rental_no = rental_no_in;



cursor_row complaint_cursor%rowtype;

v_tenant_name varchar2(30) := '';

c_count number(2) := 0;

v_tenant_name varchar2(50) := tenant_function(rental_no_in);

c_count varchar2(50) := complaints_qty(rental_no_in);

begin

for cursor_row in complaint_cursor loop --> look this line

dmbs_output.put_line(v_tenant_... '||complaint_row.rental_date||' '||c_count);

end loop;

end;



The errors



When you create a variable, must identify datatype



v_tenant_name := tenant_function(rental_no_in); --> is wrong



v_tenant_name varchar2(50) := tenant_function(rental_no_in); --> is ok



you dont need to create a variable



cursor_row complaint_cursor%rowtype;



Is automatic when user "for loop"
xamayca.com
2006-09-28 12:28:08 UTC
Great Question with all the right details. Your problem is with these two lines (if you fix only the first, it will give you the same error for line 11) :

v_tenant_name := tenant_function(rental_no_in);

c_count := complaints_qty(rental_no_in);



This is illegal. The error message is telling you what you need to do - declare these variables correctly, e.g.

v_tenant_name varchar2(100); c_count number(3);



You may then assign values to these variables in the body of your procedure by calling the functions either with values or variables (that have been given a value), e.g.

...

begin

....

v_tenant_name := tenant_function(rental_no_in);

c_count := complaints_qty(rental_no_in);

for complaint_row in complaint_cursor

loop

....

end;

/
casaliggi
2016-10-18 06:22:37 UTC
relies upon lots on what form of progression you have been doing in the previous - just about each language has replaced to a pair degree or different interior the final decade...even sturdy previous Cobol have been given a significant facelift in 2002.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...