Put delay time or sleep time when executing sql

kirubagari's Avatar, Join Date: Apr 2011
Go4Expert Member
Code:
EXEC SQL EXECUTE 
     BEGIN 
        INSERT INTO caruser.fwcarrierhistory_hist
          (sysid, carrierid, carriertype, carrierstate, carrierstatus,
         componentqty, lotid, LOCATION, activity, txntime, txncomment,
         cleancount, usedcount, lastcleandate, grouphistkey, txnkey,
         username)
        SELECT sysid, carrierid, carriertype, carrierstate, carrierstatus,
         componentqty, lotid, LOCATION, activity, txntime, txncomment,
         cleancount, usedcount, lastcleandate, grouphistkey, txnkey,
         username
       FROM caruser.fwcarrierhistory
         WHERE sysid = :sysId; 
        DELETE FROM caruser.fwcarrierhistory
        WHERE sysid = :sysId;
        WAITFOR DELAY '00:00:59';
        INSERT INTO caruser.fwcarrierhistory_pn2m_hist 
           (fromid, linkname, SEQUENCE, valtype, valdata, keytype,
         keydata)
        SELECT fromid, linkname, SEQUENCE, valtype, valdata, keytype, keydata
       FROM caruser.fwcarrierhistory_pn2m 
        WHERE fromid = :sysId; 
        DELETE FROM caruser.fwcarrierhistory_pn2m 
        WHERE fromid = :sysId;
        WAITFOR DELAY '00:00:59';
        INSERT INTO caruser.fwcarriercomment_hist 
           (sysid, commentcode, briefdescription, detaildescription)
        SELECT sysid, commentcode, briefdescription, detaildescription
       FROM caruser.fwcarriercomment 
        WHERE sysid = :txnComment; 
         DELETE FROM caruser.fwcarriercomment 
       WHERE sysid = :txnComment;
         COMMIT;
     END; 
  END-EXEC
;

Attach my sql and i need to put wait for delay command so that the sql will process after 59 second to optimize cpu usage.I dont know how to handle the scenario.
The changes is i want to reduce no. of records per query compared to current one.I might need to put delay
0
pein87's Avatar
Ambitious contributor
http://msdn.microsoft.com/en-us/library/ms187331.aspx