Results 1 to 6 of 6

Thread: Waitfor NULL

  1. #1
    Join Date
    Jun 2004
    Posts
    8

    Unanswered: Waitfor NULL

    I have an issue where I am trying to copy between 10-100 TIFF images to a directory, use the command line to combine them (I have a command line driven utility to accomplish this), copy the combined TIFF to another directory, and move to another set of TIFF images.

    I can't figure out to make SQL wait for xp_cmdshell to return NULL and then move through the loop. Is there a way to use WAITFOR to look to see what is returned and then move on?

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    It will return when done. It is synchronous. It wil wait. Are you seeing something different?

    To perform asynchronous commands you need to launch jobs.

    What are you seeing?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Jun 2004
    Posts
    8
    The problem is that I have a while statement looping through a record set in a cursor. For each record in the set it sends a command to the command prompt. Because it moves quickly through the record set it does not wait for the command prompt action to finish. It just sends it and moves on. I would like it to wait until I know the command prompt finishes its job before continuing.

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Can you post some code? Please also read the sticky at the top of the forum and post what it asks for.
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Is there some end-result you can test for? Say the existence of the final product?

  6. #6
    Join Date
    Jun 2004
    Posts
    8

    Here's some of the code

    SELECT F1.ID AS Account, LoanAppCFData.FieldValue AS Suffix, dBooked, F1.App_Number, F1.Name_1_Last, F1.Name_1_First, F1.Amount_Requested, F1.Status, F.[Description],
    'Copy \\Server1\imagelocation\' + L.DirDate+'\'+ L.[FileName] + ' Copy \\Server2\imagelocation\Images' Command
    into #Temp
    FROM LoanAppCFData INNER JOIN
    LoanApp ON LoanAppCFData.LoanID = LoanApp.Counter INNER JOIN Files F INNER JOIN
    FIELDS1 F1 ON F.DocCounter = F1.RecordCounter ON LoanApp.RecordCounter = F1.RecordCounter Left outer join Links L on L.FileCounter = F.FileCounter
    and L.DocCounter = F.DocCounter
    WHERE (LoanAppCFData.FieldID = 10003) and F.FileType not in(1,91,99) and dBooked is not null
    and L.FileType not in(1,91,99) and dBooked between Getdate()-1 and GetDate()

    DECLARE Image_Cursor CURSOR FOR
    Select Command from #Temp
    Open Image_Cursor

    Declare @Command varchar(100)
    Fetch Next FROM Image_Cursor into @Command
    EXEC Master..xp_cmdShell @Command
    WHILE @@FETCH_STATUS = 0
    BEGIN

    Fetch Next FROM Image_Cursor into @Command
    EXEC Master..xp_cmdShell @Command
    END

    Close Image_Cursor
    DEALLOCATE Image_Cursor

    Drop table #temp

    /************************************************** *********/
    Basically I'm copying images from one server to another via xp_smdshell. However, because the SQL can move through the record set very quickly, it doesn't wait for the copy command to finish before it initiates. I am looking to add another command after the copy command that will combine the TIFF images into one image and it will also return NULL. If I can't wait for the command prompt to finish what it's doing the system will combine the wrong images together.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •