Search Postgresql Archives

Re: [PGSQL 8.2.x] INSERT+INSERT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




I think it would be greatly helpful if the insert...returning could be
seen as a "select" statement and, thus, being usable in the way I
have described. I suspect that the insert...returning is actually
implemented as an inser plus a select.

You can create a function which does the INSERT RETURNING and returns the result, and use this function in a subsequent INSERT.

	You can also write, in plpgsql :

	FOR a,b,c IN SELECT ... LOOP
		INSERT INTO table1 (...) VALUES (a,b) RETURNING your_id INTO _var;
		INSERT INTO table2 (...) VALUES (c , _var );
	END LOOP


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux