Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sqlserver to Oracle
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00678830
Message ID:
00679805
Vues:
19
Leroy,
Unfortunately for developers, Oracle's PL/SQL engine hasn't caught up to its SQL engine. While the SQL engine understands the CASE statement in 8i, the PL/SQL parser doesn't. I believe this has been fixed in 9i. You can get around this using a temporary table.

Prior to executing your PL/SQL function, create a temporary table to hold your results.
create global temporary table T_TEMP (field1 number);
Then you can use it and dynamic SQL to get what you want.
declare
   nretval number := 0;
   cSQL varchar2(2000);
begin
   cSQL := 'truncate table T_TEMP';
   execute immediate cSQL;
   cSQL := 'insert into T_TEMP (select sum( case when 1 = 1 and 2 = 2 then 5 else 6 end) from dual)';
   execute immediate cSQL;
   select field1 into nretval from T_TEMP;
   dbms_output.put_line('Value: ' || to_char(nretval));
end;
Determine upfront what you want to store and create a temp table using that structure. Once you have the results, you can use a cursor to go through all the values (if more than one) and do whatever processing you want.

HTH.

>Hi Everyone!!!
>Larry Miller posted a message about the change oracle made to allow the case statement
>in sql Code see Thread#661027 Message#662099.
>But I am having problems in a PL/SQL Procedure.
>I can't use a decode because i am trying to use code like:
>
>  sum( case
>         when z = 123 and y = 432
>         then 'hello World'
>  end) as SomeTotal
>
>So I guess my question is How can I get around this?
>Thanks in advance
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform