Home » SQL & PL/SQL » SQL & PL/SQL » Not getting the result
Not getting the result [message #263214] Wed, 29 August 2007 07:16 Go to next message
navinphavade
Messages: 7
Registered: March 2007
Location: Pune
Junior Member
Hi

i have simple block

declare
i number;
s number;
begin
for i in 0 .. 14
loop
s := s + (i * 14) ;
end loop;
dbms_output.put_line(s);
end;


But i am not getting the answer of s.

Re: Not getting the result [message #263218 is a reply to message #263214] Wed, 29 August 2007 07:28 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
Initialize s to 0.

Adding anything to a null value results in a null value
Re: Not getting the result [message #263219 is a reply to message #263214] Wed, 29 August 2007 07:29 Go to previous messageGo to next message
Michel Cadot
Messages: 64140
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
First,
Please read and follow OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format. Use the "Preview Message" button.
Please always post your Oracle version (4 decimals).

Then
s is not initialized, so it is NULL and any aritmhetical operation on NULL returns NULL.
In the end, s is NULL and you got an empty line.

Regards
Michel
Re: Not getting the result [message #263227 is a reply to message #263214] Wed, 29 August 2007 07:43 Go to previous message
joy_division
Messages: 4643
Registered: February 2005
Location: East Coast USA
Senior Member
...and you need to set serveroutput on
Previous Topic: Comparing columns from different tables (merged by LF)
Next Topic: SQL query with the parameters substituted
Goto Forum:
  


Current Time: Fri Dec 09 05:47:52 CST 2016

Total time taken to generate the page: 0.12059 seconds