Skip to content

Instantly share code, notes, and snippets.

@velll
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save velll/11374606 to your computer and use it in GitHub Desktop.

Select an option

Save velll/11374606 to your computer and use it in GitHub Desktop.
BULK COLLECT initializes collection
-- Bulk collect leaves collection NOT NULL when no rows got
DECLARE
nt NUMBER_TABLE; -- does not change if you initialize it like ':= NUMBER_TABLE()'
BEGIN
SELECT 1
BULK COLLECT INTO nt
FROM DUAL
WHERE 1 = 2;
IF nt IS NULL THEN
RAISE_APPLICATION_ERROR(-20100, 'nt is null');
ELSE
RAISE_APPLICATION_ERROR(-20100, 'nt is not null: ' || nt.COUNT || ' rows');
END IF;
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment