Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2003
    Posts
    1,605

    Unanswered: how to write "wait for n secounds" in db2 script

    Hi,

    I would like to write db2 script that will execute first part of the script then wait for 10 secounds and then execute the rest of the script. Is there any command witch will do the "wait for 10 secounds"?

    My system: win2k, db2v7.2 fp5.

    Thanks,
    Grofaty

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: how to write "wait for n secounds" in db2 script

    This is from Graeme Birchall's SQL Cookbook for V8 ... I assume this will work with V7 also ... This query will execute for 4 seconds ... So you can use this to delay for 4 seconds ... But remember, you will still be using CPU cycles ..

    Cheers
    Sathyaram

    WITH TEMP1 (NUM,TS1,TS2) AS
    (VALUES (INT(1)
    ,TIMESTAMP(GENERATE_UNIQUE())
    ,TIMESTAMP(GENERATE_UNIQUE()))
    UNION ALL
    SELECT NUM + 1
    ,TS1
    ,TIMESTAMP(GENERATE_UNIQUE())
    FROM TEMP1
    WHERE TIMESTAMPDIFF(2,CHAR(TS2-TS1)) < 4
    )
    SELECT MAX(NUM) AS #LOOPS
    ,MIN(TS2) AS BGN_TIMESTAMP
    ,MAX(TS2) AS END_TIMESTAMP
    FROM TEMP1;



    Originally posted by grofaty
    Hi,

    I would like to write db2 script that will execute first part of the script then wait for 10 secounds and then execute the rest of the script. Is there any command witch will do the "wait for 10 secounds"?

    My system: win2k, db2v7.2 fp5.

    Thanks,
    Grofaty
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Jan 2003
    Posts
    1,605
    Hi,

    This is OK. The only think I don't like is that it occupyes CPU...

    Thanks,
    Grofaty

  4. #4
    Join Date
    Jan 2015
    Posts
    1
    Quote Originally Posted by sathyaram_s View Post
    This is from Graeme Birchall's SQL Cookbook for V8 ... I assume this will work with V7 also ... This query will execute for 4 seconds ... So you can use this to delay for 4 seconds ... But remember, you will still be using CPU cycles ..

    Cheers
    Sathyaram

    WITH TEMP1 (NUM,TS1,TS2) AS
    (VALUES (INT(1)
    ,TIMESTAMP(GENERATE_UNIQUE())
    ,TIMESTAMP(GENERATE_UNIQUE()))
    UNION ALL
    SELECT NUM + 1
    ,TS1
    ,TIMESTAMP(GENERATE_UNIQUE())
    FROM TEMP1
    WHERE TIMESTAMPDIFF(2,CHAR(TS2-TS1)) < 4
    )
    SELECT MAX(NUM) AS #LOOPS
    ,MIN(TS2) AS BGN_TIMESTAMP
    ,MAX(TS2) AS END_TIMESTAMP
    FROM TEMP1;
    Great post!
    very creative!
    Thanks!

  5. #5
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    Quote Originally Posted by grofaty View Post
    Hi,
    The only think I don't like is that it occupyes CPU...
    Grofaty
    For Windows, you may create a .bat file that:
    - calls script 1
    - timeout n
    - calls script 2
    This does not take CPU

    Edit: Now I've noticed that I've responded to a 12 years old post
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  6. #6
    Join Date
    Jul 2013
    Location
    Moscow, Russia
    Posts
    666
    Provided Answers: 55
    Hi,

    db2 CLP can execute OS commands. So, you can try something like this:

    db2 -tf myscript.sql

    with the following contents of the myscript.sql file:

    Code:
    values current timestamp;
    !ping -n 1 -w 10000 1.1.1.1 > nul;
    values current timestamp;
    Regards,
    Mark.

Posting Permissions

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