EXIT STATMENT IN LOOP
i want loop exit when there is no record
loop
select * from emp;
exit when %norecordfound;
end loop;
wut's wrong with this exit statment
Change your code. Since it is Pl/sql code, you can't write with out INTO clause.
So u can use either CURSOR or SELECT INTO statement. Remember the SELECT into should return single value each time in the loop.
DECLARE
V1 table.c1%type;
BEGIN
loop
SELECT c1 into V1 from TABLE;
EXIT WHEN SQL%NOTFOUND;
end loop;
Cursor attribute %NOTFOUND can be used with Cursor name you have declared for the same purpose
Cheers
Ram
Message was edited by:
user504044
Similar Messages
-
Which system variable is reset at the exit of a loop of an internal table
which system variable is reset at the exit of a loop of an internal table
a)sy-loop b)sy-index c)sy-dbcnt d)sy-tabixYou might want to revist your threads from Friday, and award points and mark as "Answered" or "Solved".
Regards,
Rich Heilman -
How to terminate or exit a for loop when the user clicks on stop button
Actually my problem is to stop a loop when i click on stop button.
example:i have two buttons 'start' and 'stop'
in start buttom i wrote a for loop as
dim i as integer
For i=1 To 100000
print i
Next
when i click on start buuton it prints 'i' value up tp 100000.
my question is when i click on 'Stop' button the for loop has to terminate or Exit from the loop and should stops the execution.
Is it possible to termianate or Exit the 'for loop'
PS.Shakeer Hussain
HyderabadI am unable to stop the loop and application not at all allowing to Press the Stop button.
It seems like Hung, any advise ?
Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
btnStop.Enabled = True
btnSelectFile.Enabled = False
btnStart.Enabled = False
btnStop.Focus()
Dim strFileName As String = txtFileName.Text.ToString
Dim strLineText As String
If System.IO.File.Exists(strFileName) = True Then
Dim objReader As New System.IO.StreamReader(strFileName)
While objReader.Peek() <> -1 And stopclick = False
strLineText = objReader.ReadLine()
MsgBox(strLineText, MsgBoxStyle.Information)
Application.DoEvents()
Thread.Sleep(My.Settings("strDelay") * 1000)
'System.Diagnostics.Process.Start(My.Settings("strFireFoxLocation"), strLineText)
End While
End If
End Sub
Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles btnStop.Click
stopclick = True
btnSelectFile.Enabled = True
btnStart.Enabled = True
btnStop.Enabled = False
End Sub
Raman Katwal
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
hi guys,
does anyone know the correct way to exit a server loop, at the moment i have ....
while(!SrvInput.getEndProgStatus()){
sk = skt.accept();
System.out.println("Accepting new client connection");
serverThread st = new serverThread(sk, conn);
st.start();
this just loops around creating a new thread for every client that connects, i have a class SrvInput which reads input from the console so if the user types "quit" the end prog status flag is set to true and the server exits.
the problem is that for it to exit i need one more person to connect since it blocks on the accept call.
Does anyone know how i can sort this out
thanks for any helpHi.
I'm trying to solve the same problem. I solve it, sending myself a Socket conection and then existing the while code like this:
public void run()
while (!isFinish())
try
System.out.println("Waiting for connections.");
Socket client = serverSocket.accept();
if (!isFinish())
System.out.println("Accepted a connection from: "+client.getInetAddress());
LocationThread connect = new LocationThread(client);
}catch(Exception e)
System.out.println(e.getMessage());
e.printStackTrace();
try
System.out.println("Server exiting");
join(); // remove join(), this a test.....
serverSocket.close();
System.out.println("Server has exit");
}catch(Exception e)
System.out.println("Error al cerrar el Socket");
}This code belongs to the server side.
I do this, in a Button in a GUI interface.
try{
location.setFinish(true);
Socket s = new Socket(InetAddress.getLocalHost(),Integer.parseInt(result));
}catch(Exception e)
System.out.println("Error al tratar de terminar el servidor");
}But I have a problem, I want my server to wait for their childs to finish, How can I do it?.
a Join() , do the server to hang.
Any suggestion ?. -
How to exit from a loop on 2 different conditions
Hello Experts
I’m trying to write a procedure in which I’m taking PROVINCE as an input parameter. All the provinces are stores in a table. I’m using a cursor and rowtype variable to check the province. After I finds province I displays province and its code. Everything works fine expect when I don’t find the province. I’m not sure how to exit from loop if I don’t find the province. I already uses exit when condition. I was expecting else condition should work and should exit from the loop but it doesn’t. Can please somebody show me how to exit if I don’t find province in the table through cursor.
Here is my code
set serveroutput on
variable G_TAX varchar2(10)
CREATE OR REPLACE PROCEDURE p_create(i_state VARCHAR2)is
CURSOR cur_bb_tax is
select * from bb_tax;
bb_tax_details bb_tax%rowtype;
begin
if not cur_bb_tax%isopen then
open cur_bb_tax;
end if;
loop
fetch cur_bb_tax into bb_tax_details;
if (bb_tax_details.state = i_state) then
dbms_output.put_line(bb_tax_details.state || bb_tax_details.idstate);
end if;
exit when bb_tax_details.state = i_state;
end loop;
close cur_bb_tax;
exception
when others then
dbms_output.put_line(SQLERRM);
end;
Thanks in advanceHello,
Why don't you use dbms_output.Put_line and print output to find why logic is not able to execute? Maybe upper case/lower case/whitespace. *Also put your code between \ to preserve formatting*.
Regards -
How to EXIT the while loop in Event response section?
I'm writing a program to grab image using a NI card. The application uses the Event structure. When the GRAB button was pressed, it snaps image continually by putting the SNAP function in a while loop. Is there some way to exit the while loop?(Note :The while loop was put in the GRAB IMAGE event response section.)
edit this event-case AND uncheck "lock front panel until the event case for this event completes".
BTW, your thanks should go to Ankita, <a href='http://forums.ni.com/ni/board/message?board.id=170&message.id=151282'>here</a>
cheers!
Message Edited by Dynamik on 11-13-2005 01:26 AM
Message Edited by Dynamik on 11-13-2005 01:38 AM
When they give imbeciles handicap-parking, I won't have so far to walk!
Attachments:
untitled.GIF 20 KB -
Stopping output tasks properly before exiting a For-loop
Hi,
I've been having some trouble exiting a For-loop conditionally. The problem is that when the loop is stopped conditionally (a button is pressed) the DAQ (NI USB 6353) outputs get stuck to whatever value they were in. I tried stopping the DAQ Assistant output task (1 sample on demand) before exiting the loop but that didn't solve the problem. Should this perhaps be done one iteration before exiting the loop or can it be done in the same iteration round?
What would be the "right" way to exit a for loop with output tasks so that the output signals would be 0V after exiting? I know that I could "force" feed the DAQ Assistant with 0V control before exiting but in this case that would be quite difficult...
Any ideas? Help is appriciated.Yes, I get it... However at this point I don't think that's an option.
Would this kind of solution work? ( I am not able to test all possible solutions in the real system which is why I would like to get a confirmation first)
The idea is to connect the output of the "Or" port to the "Stop" -ports of the DAQ Assistants in the loop.
Edit. Will the output automatically go to 0V if I just stop the task? I am not really sure about this.
Thank you.
Attachments:
exit-loop.jpg 8 KB -
loop at itab.
if <CONDITION>
<EXIT LOOP>
endif
endloop.
this ths condition , pz tel how to exit from loopHi
Loop
statements
EXIT
Endloop.
Will comes out of the loop.
Regards,
Sreeram Kumar.Madisetty -
hie guys
i am looping at two internal tables and want to exit through an if statement when a condition specified is not met however the code exits both loops.
loop at itab1.
loop at itab2.
if itab2-value eq 0.
exit.
else.
process.
endif.
endloop.
endloop.
however its not behaving as such..i have tryed to use return statement but it still wont work. i have verified my entries and the conditions exist to be true for some entries ie itab2-value ne 0 but the program exists. please assist.
regards.
Isaac PrinceYOU CAN USE IT
BUT THE SECOND TABLA MUS BE SORTED
LOOP AT T_DOCTOS_WORK.
T_DOCTOS_FINAL-BELNR_PAGO = T_DOCTOS_WORK-BELNR.
T_DOCTOS_FINAL-BUDAT_CONCILIA = T_DOCTOS_WORK-AUGDT.
T_DOCTOS_FINAL-BUDAT_PAGO = T_DOCTOS_WORK-BUDAT.
Se tratan las partidad del proveedor
READ TABLE T_DOC_BSIK_BSAK WITH KEY
AUGGJ = T_DOCTOS_WORK-GJAHR
AUGBL = T_DOCTOS_WORK-BELNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
INDEXK = SY-TABIX.
DO .
READ TABLE T_DOC_BSIK_BSAK INDEX INDEXK.
IF T_DOC_BSIK_BSAK-AUGGJ NE T_DOCTOS_WORK-GJAHR OR
T_DOC_BSIK_BSAK-AUGBL NE T_DOCTOS_WORK-BELNR OR
SY-SUBRC NE 0.
EXIT.
ELSE.
INDEXK = INDEXK + 1.
*MAKE YOUR CODE
ENDIF.
ENDDO.
ENDIF.
ENDLOOP -
I am putting exit condition in before and after my business logic, so it make any difference
BEGIN
FOR REC IN 1..10
LOOP
EXIT WHEN REC =5;
business logic
END LOOP;
END;
BEGIN
FOR REC IN 1..10
LOOP
business logic
EXIT WHEN REC =5;
END LOOP;
END;Thanks
Edited by: Braam on Oct 11, 2012 10:24 PMWould have been quicker for you to test it yourself, than to post the question:
SQL> ed
Wrote file afiedt.buf
1 BEGIN
2 FOR REC IN 1..10
3 LOOP
4 EXIT WHEN REC =5;
5 /*
6 business logic
7 */
8 dbms_output.put_line('Processing: '||rec);
9 END LOOP;
10* END;
11 /
Processing: 1
Processing: 2
Processing: 3
Processing: 4
PL/SQL procedure successfully completed.
SQL> ed
Wrote file afiedt.buf
1 BEGIN
2 FOR REC IN 1..10
3 LOOP
4 /*
5 business logic
6 */
7 dbms_output.put_line('Processing: '||rec);
8 EXIT WHEN REC =5;
9 END LOOP;
10* END;
SQL> /
Processing: 1
Processing: 2
Processing: 3
Processing: 4
Processing: 5
PL/SQL procedure successfully completed. -
Help -- How do I exit a Foreach Loop
I have a foreach loop that is processing files in a directory. One of the tasks is the execute sql task that calls a stored proc. If this stored proc returns a certain value then I need to exit the loop and not process any more files. But I have been unable to figure out how to make this happen.
Any help would be greatly appreciated.
Thanks!
GNGN wrote:
I have a foreach loop that is processing files in a directory. One of the tasks is the execute sql task that calls a stored proc. If this stored proc returns a certain value then I need to exit the loop and not process any more files. But I have been unable to figure out how to make this happen.
Any help would be greatly appreciated.
Thanks!
GN
have you considered using the script task instead? -
Submit Statment inside Loop - Problem in display O/P
Hi All,
Iam Using Submit statment inside the Loop with Return , when the first line in the loop completes the O/P gets display and the Second line is not processed and get in O/P.Can any one let me know why this problem occurs?...
Regards,
Veerawhen You submit for a report it starts a parallel process and it is O/P then if you are doign it in loop it may be over writing the existing O/P that may be the reason you are not seeing the out put properly as it is written across different internalk sessions
-
Is there a way in a foreach loop container to exit if the foreach loop container has been executing for a certain amount of time?
Thanks.Hi miguelh,
Based on my research, there is no such a property for Foreach Loop Container to achieve this requirement. Because the Foreach Loop Container itself execute the times based on the files loop.
After testing the issue in my environment, we can add a Script Task inside the top of Foreach Loop Container to count the execute times, then add a precedence constraint with the count times on your tasks to limit the execute times. For more details, please
see:
Add a variable named Count in the package.
Drag a Script Task inside the top of Foreach Loop Container.
Double-click the Script Task, change ScriptLanguage to Microsoft Visual Basic 2010, then add User::Count as ReadOnlyVariables.
Click Edit Script to add the code like below:
Public Sub Main()
' Add your code here
Dts.Variables("User::Count").Value = Dts.Variables("User::Count").Value + 1
Dts.TaskResult = ScriptResults.Success
End Sub
Add a precedence constraint with Constraint options below:
The following screenshot is for your reference:
Thanks,
Katherine Xiong
If you have any feedback on our support, please click
here.
Katherine Xiong
TechNet Community Support -
Exiting from Inner Loop.
Example.
Loop at I_catsdb.
Loop at I_catsdb_tmp.
endloop.
endloop.
How do I come out of the inner loop on certain conditions?Hi,
Use the EXIT statement..
Loop at I_catsdb.
Loop at I_catsdb_tmp.
Check the conditions..
EXIT.
endloop.
endloop.
Thanks,
Naren -
How do I exit a while loop which has a 'read from spreadshee​t' pop up in it?
I have a while loop which calls 'read from spreadsheet'. My problem is that after entering a filename the loop repeats too quickly for me to hit the end loop button. How do I exit the loop without adding a delay after the read thereby slowing the loop when I don't want to exit. If I select cancel I get 'error 43'. Is there a way to to use an error handler to prevent this from popping up and use it to end the loop?
It's the error handler inside Read From Spreadsheet that creates the message. Specifically, one of the VIs called is Read Lines From File. The last VI in there is General Error Handler. You can delete it and save it with a different name. You should also modify it to return the error cluster. You'll also want to modify Read From Spreadsheet to return the error cluster so that you can trap the error in your VI. When cancel is selected, error code 43 is generated. Stop the loop when you see 43.
Maybe you are looking for
-
How to use a session, created in a jsp page, in a php page
Hello, forgive me for the newbie question. Here is my problem: I want to have a jsp page create a session, set some session variables and then redirect to a php page which will access those same session variables. I have the redirection worked out, b
-
How do i pass a daqmx task from labview to matlab using the math interface toolkit?
I want to use DAQMX functions from Matlab using the Math Interface Toolkit (MIT). How can I have a labview function output (return) the DAQMX task to matlab via the MIT? I want to do this so I can start a DAQMX task in Labview from a matlab function
-
Scene Detection Broken in CS6?
I'm having awful difficulty capturing video in CS6. Specifically, every 60 seconds or so CS6 keeps prompting me to save the scene it thinks it's captured, even though scene detection is *not* checked (it is off) and abort on dropped frames is also of
-
Premiere Elements - a real disappointment
I purchased Premiere Elements version 8 in Jan 2010 and had to give up on the software as it frequently crashed when working with multiple video and image files. I didn't realize that there had been two upgrades since version 8, and I now found out
-
POSTING PERIOD IN MIGO (GOOD RECEIPT)
Dear Experts I tried posting a good receipt and got this error message " POSTING ONLY POSSIBLE IN PERIODS 2011/03 AND 2011/02 FOR COMPANY CODE XX" please how do I change the posting period, so that I can carry out my Good receipt transaction succes