Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

problem with increament counter and modulus in PL/SQL?

550549Feb 8 2007 — edited Feb 8 2007
I having trouble running this simple PL/SQL programs, the program syntax look correct, but I having trouble debugging. The program want to count how many times the c7(the table columns fetches into variable c7) contains the value A0056156 and also use the modulus operator to display whether this is an even or odd count.

I would appreciated if anybody can help me on this situation


Here the program

declare
c1 char(8);
c2 char(8);
c3 varchar2(4);
c4 varchar2(100);
c5 varchar2(10);
c6 char(9);
c7 char(9);

count number;

cursor John is select * from mrrel;

begin
open John;
count := 0;
loop

fetch john into c1, c2, c3, c4, c5, c6, c7;
exit when John%notfound;

if (c7 = 'A0056156') then
count := count + 1;
end if;


end loop;
close John;

dbms.output.put_line('The number of times with column containing A0056156 is ' || count);
if mod(count, 2) > 0 then
dbms.output.put_line('The word count is odd');
else
dbms.output.put_line('The word count is even');
end if;
end;
/
show errors


----------------------------------------------------------------------------------------------------------------
Here the errors


count := count + 1;
*

ERROR at line 23:
ORA-06550: line 23, column 13:
PLS-00204: function or pseudo-column 'COUNT' may be used inside a SQL statement only
ORA-06550: line 23, column 4:
PL/SQL: Statement ignored
ORA-06550: line 30, column 96:
PLS-00204: function or pseudo-column 'COUNT' may be used inside a SQL statement only
ORA-06550: line 30, column 14:
PL/SQL: Statement ignored
ORA-06550: line 31, column 25:
PLS-00204: function or pseudo-column 'COUNT' may be used inside a SQL statement only
ORA-06550: line 31, column 17:
PL/SQL: Statement ignored
No errors.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 8 2007
Added on Feb 8 2007
11 comments
303 views