Home » SQL & PL/SQL » SQL & PL/SQL » For Loop coding problem
For Loop coding problem [message #298206] Tue, 05 February 2008 05:57 Go to next message
adilsami
Messages: 46
Registered: October 2007
Member
Can any one guide me with this code
it doesn't show any result .


declare
v_table number(4) := &table;
v_low number(4) :=&Low;
v_hi number(4) :=&Hi;
begin
for i in v_low..v_hi
loop
dbms_output.put_line (v_table * i ||' = '|| v_table * i);
end loop;
end;
/
Re: For Loop coding problem [message #298208 is a reply to message #298206] Tue, 05 February 2008 06:01 Go to previous messageGo to next message
MarcS
Messages: 312
Registered: March 2007
Location: Antwerp
Senior Member
And how do you execute this piece of code?

If I have to guess, I think SQL*plus.

Before running this code, you should execute

SQL> SET SERVEROUTPUT ON


This will enable the display of whatever you would like to see when calling DBMS_OUTPUT

HTH
Re: For Loop coding problem [message #298210 is a reply to message #298206] Tue, 05 February 2008 06:14 Go to previous messageGo to next message
adilsami
Messages: 46
Registered: October 2007
Member
hey bro , thanx alot !
Re: For Loop coding problem [message #298217 is a reply to message #298206] Tue, 05 February 2008 06:30 Go to previous messageGo to next message
adilsami
Messages: 46
Registered: October 2007
Member
i want to display the Table Number instead
the variable name..


declare
v_table number(4) := &table;
v_low number(4) :=&Low;
v_hi number(4) :=&Hi;
begin
 for i in v_low..v_hi
  loop
 dbms_output.put_line ('v_table  * ' ||i||' = '||v_table*i);
 end loop;
 end;
/

The OutPut :
v_table  * 1 = 1
v_table  * 2 = 2
v_table  * 3 = 3
v_table  * 4 = 4

Re: For Loop coding problem [message #298227 is a reply to message #298217] Tue, 05 February 2008 06:47 Go to previous message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Move 'v_table' out of the quotes:
dbms_output.put_line (v_table || ' * ' ||i||' = '||v_table*i);
Previous Topic: Replace characters in a string using sql plus
Next Topic: Retrieving data from table which has higher precedence
Goto Forum:
  


Current Time: Sat Feb 15 18:16:25 CST 2025