PostgreSql INSERT FROM SELECT RETURNING ID

You just need to add a RETURNING id to your INSERT ... SELECT:

WITH rows AS (...)
INSERT INTO dealer (user_id)
    SELECT id
    FROM rows
    RETURNING id;

Demo: http://sqlfiddle.com/#!12/75008/1


For my purposes, I needed it in a variable so I did this:

INSERT INTO dealer (user_id)
    SELECT id
    FROM rows
    RETURNING id INTO l_dealerid;