Skip to content

Instantly share code, notes, and snippets.

@avances123
Created January 26, 2015 17:17
Show Gist options
  • Save avances123/e9725ef640f99a7aa47c to your computer and use it in GitHub Desktop.
Save avances123/e9725ef640f99a7aa47c to your computer and use it in GitHub Desktop.
returning problem
CREATE TABLE pis1
(
x serial NOT NULL,
y integer,
CONSTRAINT pk_lineas PRIMARY KEY (x)
);
CREATE TABLE pis2
(
id serial,
x integer,
y integer,
CONSTRAINT pk_lineas PRIMARY KEY (id),
CONSTRAINT lineas_id_pred_pasado_fkey FOREIGN KEY (x)
REFERENCES pis1 (x) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE
);
INSERT INTO pis2 (x) SELECT pis1.x FROM pis1 JOIN generate_series(1,3) as kk ON pis1.y = kk RETURNING id,kk;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment