-
-
Save vinnix/257f544bf1380ef546ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE OR REPLACE FUNCTION proc_split_contacts() RETURNS TABLE(quantity int, total int, x_time numeric) as $body$ | |
| DECLARE | |
| i INTEGER; | |
| s INTEGER; | |
| v_time numeric; | |
| curs1_tosplit CURSOR FOR | |
| SELECT id, generation, vcard, created_by, user_id, parents, deleted, | |
| CASE WHEN deleted = true THEN COALESCE(deleted_at, updated_at) ELSE updated_at END | |
| FROM contacts WHERE in_transit = false LIMIT 500; | |
| BEGIN | |
| SELECT (EXTRACT(minute FROM current_timestamp) * 60) + EXTRACT(second FROM current_timestamp) into v_time; | |
| FOR rowvar IN curs1_tosplit | |
| LOOP | |
| RAISE NOTICE 'Contact.id(%)', rowvar.id; | |
| i := i +1; | |
| -- | |
| -- | |
| -- get logic on gist | |
| END LOOP; | |
| SELECT ((EXTRACT(minute FROM current_timestamp) * 60) + EXTRACT(second FROM current_timestamp)) - v_time into v_time; | |
| RETURN QUERY SELECT i, s,v_time ; | |
| END; | |
| $body$ LANGUAGE plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment