Skip to content

Instantly share code, notes, and snippets.

@thequbit
Created September 5, 2015 00:24
Show Gist options
  • Save thequbit/7585f3ea24b706996981 to your computer and use it in GitHub Desktop.
Save thequbit/7585f3ea24b706996981 to your computer and use it in GitHub Desktop.
UPDATE
jobs j
SET
in_process = TRUE,
start_run_datetime = now()
FROM (
SELECT
jobs.id
FROM
jobs
WHERE
jobs.in_process = FALSE
ORDER BY
jobs.last_run_datetime
LIMIT
1
) sub
WHERE
j.id = sub.id
RETURNING
j;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment