Lou,
On Wed, Mar 6, 2019 at 10:59 AM Lou <lou(at)dayspringpublisher(dot)com> wrote:
> How can I INSERT new rows into both tables simultaneously with automatically created id numbers, and how can I UPDATE both tables simultaneously?
Although I have no idea why you would want to do this, you can insert
data into two tables with one query using a common table expression:
WITH cinsert AS (
INSERT INTO c (id, name) VALUES (1, 'Jones')
RETURNING id, name)
INSERT INTO p (id, name) (SELECT * FROM cinsert);
Cheers,
Chris
--
Christopher Swingley
Fairbanks, Alaska
http://swingleydev.com/
cswingle(at)swingleydev(dot)com