Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 29-05-2009
Member
 
Join Date: Apr 2009
Posts: 91
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!
Reply With Quote
  #2  
Old 29-05-2009
Member
 
Join Date: Dec 2008
Posts: 202
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
Reply With Quote
  #3  
Old 29-05-2009
Member
 
Join Date: Jan 2006
Posts: 211
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.
Reply With Quote
  #4  
Old 29-05-2009
Member
 
Join Date: Jan 2009
Posts: 99
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 ;
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to call stored procedure using do while Loop"
Thread Thread Starter Forum Replies Last Post
Stored procedure in MySQL database Ameeryan Software Development 5 04-03-2010 10:31 PM
How to call SQL server with ASP views and stored procedure? Acalapati Software Development 4 13-02-2010 01:51 AM
How to call back Access stored procedure Radames Software Development 5 13-02-2010 12:38 AM
Use Of Stored Procedure in SQL Server technika Software Development 5 30-01-2010 11:24 AM
How to create, deploy and use DB2 stored procedure garfield1 Software Development 3 08-08-2009 11:10 AM


All times are GMT +5.5. The time now is 07:19 PM.