E
E
Eugene Wolf2016-12-08 17:45:30
PostgreSQL
Eugene Wolf, 2016-12-08 17:45:30

PostgreSQL DB row copy function, how to write correctly?

Good day dear!
There was a need to write a Posetgres function that would select a row from the database, replace several values ​​and save it as a new row. I can't think of the most elegant solution.
Selecting a row (DB entry) is no problem. The question is how to save the selected row into some object and change some of its properties, and then save this object back to the database?
*all this must be done at the Postgres function level.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2016-12-08
@Wolfnsex

insert into tablename (field1, field2, field3) 
select field1, field2, 'new values instead field3'
from tablename
/*where*/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question