creating a function with a for loop and %type
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