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!

creating a function with a for loop and %type

user10873577Jun 27 2011 — edited Jun 27 2011
Hello,
I am trying to create a function which contains a for loop as well as %type.
This function is on a student table and i am trying to create a function which will display the zip which is a varchar2(5).
I need to do this through this function.
However, I can't seem to get it running.
Can anyone help?
below is what i tried as well as other options and was not successful.
I also displayed my error with the show error command.
SQL> create or replace function zip_exist
2 return varchar2
3 is
4 v_zip student.zip%TYPE;
5 cursor c_zip is
6 select zip
7 from
8 student
9 where zip=zip;
10 begin
11 open c_zip;
12 v_zip IN c_zip
13 loop
14 v_zip:=c_zip%TYPE;
15 end loop;
16 close c_zip;
17 end;
18 /

Warning: Function created with compilation errors.

SQL> show error
Errors for FUNCTION ZIP_EXIST:

LINE/COL ERROR
-------- -----------------------------------------------------------------
12/7 PLS-00103: Encountered the symbol "IN" when expecting one of the
following:
:= . ( @ % ;

16/1 PLS-00103: Encountered the symbol "CLOSE"
SQL>

kabrajo
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 25 2011
Added on Jun 27 2011
5 comments
231 views