wait_while_jobs_are_running.ksh

When running a number of jobs in the background -- I run this in the foreground:

::/apps/datamodules/_SQL> jobs
::/apps/datamodules/_SQL> cat ../_CMD/wait_while_jobs_are_running.ksh
 export jr=`jobs|grep -c "Running"`
 while [[ $jr -ne 0 ]];do
 sleep 30
 export jr=`jobs|grep -c "Running"`
 done

...it basically sleeps 30 seconds until there are no more running jobs.

UnDup SQL pattern

    /*
    || Recording this here for reference
    || it's a pattern that will repeat
    || In theory you can do without creating
    || interim table -- in practice I've found
    || otherwise...
    || 'min_record_id' is assumed to be a 
    || unique sequential number assigned to
    || records as they come in ...
    */
    CREATE TABLE min_record_id (record_id bigint(19));
   
CREATE UNIQUE INDEX min_record_id_PK on min_record_id(record_id);
    INSERT INTO min_record_id
        SELECT *
          FROM (-- ilv
                   SELECT MIN(record_id) as record_id
                     FROM dup_file

                    GROUP
                       BY {uniquely identifying items}
               )

                  ilv
    ;
    CREATE TABLE file_unique
    SELECT  df.*
      FROM  dup_file df 

            inner join 
            min_record_id mri 
            on df.record_id
            =  mri.record_id
    ;
    DROP TABLE min_record_id;

Favorite Tweets