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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 sql server hangs or bombs

Author  Topic 

msa969
Starting Member

13 Posts

Posted - 2002-02-23 : 19:57:04
I want to print the numbers 1 to 5 to screen and then the numbers 7 9 & 10 so excluding 6 & 8.

Can you have nested if's in while loop in PL/SQL?
If so how can it be done.

Note this code is not finished simply becuase the origional code failed so I have simplified it with just if-then.

I don't know if this code works or not because it doesn't return with a answer.

set serveroutput on
DECLARE

v_counter number(2) := 1;

BEGIN

while v_counter < 11 LOOP
If v_counter < 6 then
dbms_output.put_line('result: ' || v_counter );
v_counter := v_counter + 1;
end if;
END LOOP;
END;
/





Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2002-02-24 : 04:18:08
You are confused. The code you've posted is PL/SQL, which is what Oracle uses. SQL Server uses T-SQL, which is not the same -- it's quite dissimilar as far as the syntax of procedural code is concerned.


Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-02-24 : 04:49:50
Maybe that is the problem, you are trying to run PL/SQL and it hangs. Or maybe, SQL Server isn't running at all and you are running your code on Oracle.



Sorry, I'm not helping.... I'll shut up now

Damian
Go to Top of Page
   

- Advertisement -