Home » SQL & PL/SQL » SQL & PL/SQL » please give me solution for this program
please give me solution for this program [message #289184] Thu, 20 December 2007 00:46 Go to next message
balajiags
Messages: 10
Registered: July 2007
Junior Member
hi experts
i have write the following program to print output as in given
.xls file
i tried a lot but i dont get the correct output please help me
declare
n number :=3;
m number :=10;
a number;
begin
for x in 1..n loop
for y in 1..m loop
a:=x*y;
dbms_output.put_line(a);
loop
exit when a= x*10;
exit loop;
exit loop;
exit loop;
end;
/
  • Attachment: manoj.xls.xls
    (Size: 18.00KB, Downloaded 147 times)
Re: please give me solution for this program [message #289191 is a reply to message #289184] Thu, 20 December 2007 01:09 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> declare
  2  n number :=3;
  3  m number :=10;
  4  a number;
  5  begin
  6  for x in 1..n loop
  7  for y in 1..m loop
  8  a:=x*y;
  9  dbms_output.put_line(a);
 10  loop
 11  exit when a= x*10;
 12  exit loop;
 13  exit loop;
 14  exit loop;
 15  end;
 16  /
end;
   *
ERROR at line 15:
ORA-06550: line 15, column 4:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
loop

Start with:
1/ "exit loop;" must be "end loop;"
2/ there are 3 "exit loop;" and only 2 loops

Next time: 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.
Also post your Oracle version (at least 3 decimals).

Finally copy and paste your execution with line numbers and error messages as I did.

Regards
Michel

[Updated on: Thu, 20 December 2007 01:09]

Report message to a moderator

Re: please give me solution for this program [message #289192 is a reply to message #289184] Thu, 20 December 2007 01:09 Go to previous messageGo to next message
kir_ait
Messages: 198
Registered: November 2007
Location: Bangalore,India
Senior Member

It seems your codes are not correct.

Can you check this one ?



SQL> set echo off
SQL> set serveroutput on size 4096
SQL> spool dbmsout

SQL> declare
  2  n number :=3;
  3  m number :=10;
  4  a number;
  5  begin
  6  for x in 1..n loop
  7  for y in 1..m loop
  8  a:=x*y;
  9  dbms_output.put_line(a);
 10  exit when a= x*10;
 11  end loop;
 12  end loop;
 13  end;
 14  /
1
2
3
4
5
6
7
8
9
10
2
4
6
8
10
12
14
16
18
20
3
6
9
12
15
18
21
24
27
30

PL/SQL procedure successfully completed.

[Updated on: Thu, 20 December 2007 01:10]

Report message to a moderator

Re: please give me solution for this program [message #289437 is a reply to message #289184] Fri, 21 December 2007 12:25 Go to previous message
Bill B
Messages: 1482
Registered: December 2004
Senior Member
balajiags wrote on Thu, 20 December 2007 00:46

hi experts
i have write the following program to print output as in given
.xls file
i tried a lot but i dont get the correct output please help me
declare
n number :=3;
m number :=10;
a number;
begin
for x in 1..n loop
for y in 1..m loop
a:=x*y;
dbms_output.put_line(a);
loop
exit when a= x*10;
exit loop;
exit loop;
exit loop;
end;
/


This code will NOT produce an XLS file, An XLS file is a binary file and can't be produced by a sql spool. You can make a csv file. Do not use xls as the extension.
Previous Topic: virtual column 11g new feature
Next Topic: selecting date interval
Goto Forum:
  


Current Time: Sun Dec 04 06:31:03 CST 2016

Total time taken to generate the page: 0.06005 seconds