Results 1 to 4 of 4

Thread: How to call stored procedure using do while Loop

  1. #1
    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!

  2. #2
    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.

    CREATE PROCEDURE dbo.GetVal AS
    SELECT HandlingCountry , EmployeeID FROM tbl_loginaccount
    GO

  3. #3
    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.

  4. #4
    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 ;

Similar Threads

  1. Stored procedure in MySQL database
    By Ameeryan in forum Software Development
    Replies: 5
    Last Post: 04-03-2010, 10:31 PM
  2. How to call SQL server with ASP views and stored procedure?
    By Acalapati in forum Software Development
    Replies: 4
    Last Post: 13-02-2010, 01:51 AM
  3. How to call back Access stored procedure
    By Radames in forum Software Development
    Replies: 5
    Last Post: 13-02-2010, 12:38 AM
  4. Use Of Stored Procedure in SQL Server
    By technika in forum Software Development
    Replies: 5
    Last Post: 30-01-2010, 11:24 AM
  5. How to create, deploy and use DB2 stored procedure
    By garfield1 in forum Software Development
    Replies: 3
    Last Post: 08-08-2009, 11:10 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,020,667.80926 seconds with 16 queries