views:

26

answers:

2

I am working on form6i and using case expression in cursor.But the following code is not compiling Is Forms 6i not support the case expression in cursor or any method to write case expression in forms

+1  A: 

It's because the pl/sql engine used in Forms 6i is "old" and wasn't aware of CASE statements when it was developed. (As I recall, server side pl/sql only introduced CASE statements at Oracle 9i)

I don't have a copy of form builder 9i so can't comment on that version but CASE statements are available in Forms 10g and above.

carpenteri
CASE was available in Oracle 8i, but not (directly) in PL/SQL programs. But Forms PL/SQL lagged (significantly) behind the server PL/SQL. I *think* it was only 10gR2 Forms that could manage CASE.
Gary
+3  A: 

In almost all cases I can think of, you can use nested decodes instead of case.

Instead of

 select case when a=1 then 'foo'
             when b>2 then 'bar'
             else 'foobar' end
   from xyz;

you can write

 select decode(a,1,        'foo',
        decode(sign(b-2),1,'bar',
                           'foobar')) from xyz;

The other, probably more elegant possibility, is to create a database view and use it in forms, so forms 6i never sees the case.

ammoQ
+1 I should have included a solution like yours in my response rather than just explaining why it wouldn't work.
carpenteri