Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: CASE strucrure in PL/SQL

Re: CASE strucrure in PL/SQL

From: Rob Cowell <rjc4687_at_hotmail.com>
Date: Wed, 04 Jun 2003 08:09:42 +0100
Message-ID: <3EDD9B36.52EB9F8A@hotmail.com>

Onismus Radebe wrote:
>
> Is CASE strucrure supported in PL?
>

Did you guess that syntax or look it up in the manual?

http://download-east.oracle.com/docs/cd/B10501_01/appdev.920/a96624/13_elems5.htm#36890

LOOP

	CASE i
		WHEN 1 THEN v_department_id := 10




> SQL> list
> 1 DECLARE
> 2 TYPE department_table_type IS TABLE OF
> 3 departments%ROWTYPE
> 4 INDEX BY BINARY_INTERGER ;
> 5 department_table department_table_type ;
> 6 v_department_id departments.department_id%TYPE ;
> 7 c_counter CONSTANT NUMBER(2) := 7 ;
> 8 BEGIN
> 9 FOR i IN 1..7
> 10 LOOP
> 11 v_department_id :=
> 12 CASE i
> 13 WHEN 1 THEN 10
> 14 WHEN 2 THEN 20
> 15 WHEN 3 THEN 50
> 16 WHEN 4 THEN 60
> 17 WHEN 5 THEN 80
> 18 WHEN 6 THEN 90
> 19 WHEN 7 THEN 110
> 20 END ;
> 21
> 22 SELECT *
> 23 INTO department_table(i)
> 24 FROM departments
> 25 WHERE department_id = v_department_id
> 26 END LOOP ;
> 27
> 28 FOR i IN department_table.FIRST..department.LAST
> 29 LOOP
> 30 DBMS_OUTPUT.PUT_LINE (CHR(10)) ;
> 31 DBMS_OUTPUT.PUT_LINE (department_table(i).department_name) ;
> 32 END LOOP ;
> 33* END ;
> SQL>
>
> SQL> @0502
> CASE i
> *
> ERROR at line 12:
> ORA-06550: line 12, column 4:
> PLS-00103: Encountered the symbol "CASE" when expecting one of the
> following:
> ( - + mod not null <an identifier>
> <a double-quoted delimited-identifier> <a bind variable> avg
> count current exists max min prior sql stddev sum variance
> execute forall time timestamp interval date
> <a string literal with character set specification>
> <a number> <a single-quoted SQL string>
>
> --
> Onismus
Received on Wed Jun 04 2003 - 02:09:42 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US