Home » Other » Client Tools » hi - I need help with while santence
hi - I need help with while santence [message #339965] Sun, 10 August 2008 08:17 Go to next message
levindi
Messages: 6
Registered: August 2008
Junior Member
I tried this code:


DECLARE
x NUMBER ( 2 ) := 1;
BEGIN
WHILE x <> 10 LOOP
x:=&enter_x;
[here I want to enter any procedure]
END LOOP;

END;

I want the user will enter every time a number and if the number is different from 10 the procedure will start.
this code stuck my sqldeveloper.

Thanks for the help,
Re: hi - I need help with while santence [message #339966 is a reply to message #339965] Sun, 10 August 2008 08:24 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You can't do it that way.
PL/SQL block is executed by the server, so SQL*Developer (or SQL*Plus) asks you the value once, then it sends the block to the server. Insiide the server there is no more &enter_x there is the value you entered.

Regards
Michel
Re: hi - I need help with while santence [message #339967 is a reply to message #339965] Sun, 10 August 2008 08:45 Go to previous messageGo to next message
levindi
Messages: 6
Registered: August 2008
Junior Member
thank you,
I tried to trick it by this:

begin

while i<x LOOP
i:=i+1;
v_item :=&enter_which_item_to_order;
v_quantity :=&enter_how_much_do_you_want;
insert_orders_details(v_item=>v_item,
v_quantity=>v_quantity);
end loop;
end;

also with for..loop, it asked me just once for number:


v_p:=&how_much_diff_items_you_want?;
for i in 1..v_p LOOP
v_item := &enter_which_item_to_order;
v_quantity := &enter_how_much_do_you_want;

insert_orders_details(v_item=>v_item, v_quantity=>v_quantity);

end loop;
end;

help? thanks

[Updated on: Sun, 10 August 2008 09:02]

Report message to a moderator

Re: hi - I need help with while santence [message #339968 is a reply to message #339965] Sun, 10 August 2008 09:25 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/t/88153/0/
Please read & FOLLOW the Posting Guidelines as stated in URL above
Re: hi - I need help with while santence [message #339969 is a reply to message #339967] Sun, 10 August 2008 09:26 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What you have to understand is the difference between what is done on client and what is done on server.

conversion &x -> its value is done in client.
Once ALL the "&" variables are substitute by their values then the block is sent ONCE AND ONLY ONCE to the server where it is executed.
So you can't ask several times a value: there is no back and forth between client and server.

Regards
Michel

[Updated on: Sun, 10 August 2008 09:26]

Report message to a moderator

Re: hi - I need help with while santence [message #339970 is a reply to message #339969] Sun, 10 August 2008 09:38 Go to previous message
levindi
Messages: 6
Registered: August 2008
Junior Member
thank you very much,
now I understand it!
Previous Topic: SQLPlus commands
Next Topic: Free GUI tool (like toad )required for running SQL/PL/SQL
Goto Forum:
  


Current Time: Thu Mar 28 12:22:56 CDT 2024