How to call stored procedure using do while Loop
I have written all the stored procedure that returns a table that contains required fields those fields are 6 to 7 in numbers but my requirement is that when i will assign the condition at top it need to check it first if it satisfies that criteria then only it should go further and print the value, while doing this it should go inside atleast once and print the value.
Thank for your help in Advance!
Re: How to call stored procedure using do while Loop
Creates a stored procedure, which is a saved collection of Transact-SQL statements that can take and return user-supplied parameters.
Procedures can be created for permanent use or for temporary use within a session (local temporary procedure) or for temporary use within all sessions (global temporary procedure).
Here i have given an example where you could find about how to create the stored procedure.
Quote:
CREATE PROCEDURE dbo.GetVal AS
SELECT HandlingCountry , EmployeeID FROM tbl_loginaccount
GO
Re: How to call stored procedure using do while Loop
Stored Procedures are faster, because they eliminate the need to reparse and reoptimize the requests each time they're executed. When a CREATE PROCEDURE statement is executed successfully, the procedure name is stored in the sysobjects system table and the text of the CREATE PROCEDURE statement is stored in syscomments. When executed for the first time, the procedure is compiled to determine an optimal access plan to retrieve the data. The most common reason to use a stored procedure is for database intensive processing that produces only small amounts of result data. This can save a large amount of communications across the network during the execution of the stored procedure.
Re: How to call stored procedure using do while Loop
A stored procedure is a group of SQL statements that form a logical unit and perform a particular task. Is a parameter in the procedure. One or more parameters can be declared in a CREATE PROCEDURE statement.Stored procedures are used to encapsulate a set of operations or queries to execute on a database server.
Code:
CREATE PROCEDURE RepeatLoopProc()
BEGIN
DECLARE x INT;
DECLARE str VARCHAR(255);
SET x = 1;
SET str = '';
REPEAT
SET str = CONCAT(str,x,',');
SET x = x + 1;
UNTIL x > 5
END REPEAT;
SELECT str;
END$$
DELIMITER ;