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!

Code correction - PL/SQL

Albert ChaoJul 28 2021 — edited Jul 28 2021

Can someone please correct the code below. The code is to find perfect numbers between 1 to 100

set serveroutput on;
DECLARE
sum NUMBER;
p NUMBER;
BEGIN
dbms_output.put_line('Perfect numbers between 1 and 100 are :');
p := 1;
FOR i IN i..100

LOOP
while(p<=(i/2))
end loop;

if(mod(i,p)=0) then
sum := sum +p;
p := p+1;
end if;
end loop;
if(sum = i)
dbms_output.put_line ( i|| ' ' ) ;
SUM := 0 ;
END ;

Comments

I suspect that you have the problem of the pass-through scenario.
Your NLS_LANG and Unicode locale are set to AL32UTF8 but
your terminal works in WE8ISO8859P1. Hence, you can enter
and retrieve your data but they are not stored legal AL32UTF8 codes.
This only suspicion, therefore please do the following test:

INSERT INTO <your_table>(<your_CLOB_COLUMN>)
VALUES( UNISTR('\00e4\00f6\00fc\00df') );

and query this value back. If you correctly see three German lowercase umlauts
and sharp s, then my diagnosis is wrong and I will try again.

Otherwise, set NLS_LANG=.WE8ISO8859P1 and restart your tests.


-- Sergiusz
361551
No, my terminal works with UFT-8 encoding.
I called your SQL-Statement twice, from windows and from UNIX, and I can see these four characters displayed correctly on the both sides.

Dzianis
Please, specify the exact database and client versions.

-- Sergiusz
Also, please post the code fragment that reports the error.

-- Sergiusz
361551
Server and Client have the same version number:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
361551
The OCI function is OCILobRead.
1 - 6

Post Details

Added on Jul 28 2021
6 comments
609 views