Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 PL/SQL output

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-12-22 : 11:31:51
Deepak writes "I am running a query which is presently duplicating the last record retrieved. How can I ammend the following query to stop it doing this:

set serveroutput on 50000
declare
tot_rows number;
icount number := 0;
itemp varchar2(12);
cursor c1 is
select k_company from trnzuser.loctest WHERE K_COMPANY IN
(SELECT DISTINCT(K_COMPANY)
FROM TRNZUSER.location);
begin
DBMS_OUTPUT.PUT_LINE ('DELETE FROM TRNZUSER.LOCTEST WHERE K_COMPANY in (' );
open c1;
loop
fetch c1 into tot_rows;
exit when c1%notfound;
if icount > 99 then--counter is here due to buffer size limits.
icount := 0;
end if;
DBMS_OUTPUT.PUT_LINE (tot_rows||',');
icount := icount + 1;
END LOOP;
close c1;
--the following line is causing the final record to be
duplicated--
select decode(tot_rows,',',' ') into itemp from dual;
dbms_output.put_line(itemp||')'||';');
end;

Using oracle 8i

Thanks in advance."
   

- Advertisement -