Can 'UNION ALL' be used with 'INSERT INTO' in postgres?
<p>Can I write something like this in postgres 9.4?</p>

<pre><code>SELECT id FROM image_instance WHERE name = 'bioboxes/velvet-then-quast'

UNION ALL

INSERT INTO image_instance (name, sha256, image_type_id)
SELECT
    'bioboxes/velvet-then-quast',
    'digest_4',
    (SELECT id FROM image_type WHERE name = 'short_read_preprocessing_reference_evaluation')
WHERE NOT EXISTS (SELECT id FROM image_instance WHERE name = 'bioboxes/velvet-then-quast')
RETURNING id
</code></pre>

<p>I get a syntax error on the <code>INSERT</code> so I assume this is not possible? I thought it worth asking in case I am writing this incorrectly.</p>

<p>I know that this is not thread safe, however this is for a single threaded application.</p>