Insert if not exists, else return id in postgresql

后端 未结 3 1955
無奈伤痛
無奈伤痛 2020-11-29 18:51

I have a simple table in PostgreSQL that has three columns:

  • id serial primary key
  • key varchar
  • value varchar

I have already see

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 19:03

    And you can store value returned to variables in form of ... RETURNING field1, field2,... INTO var1, var2,...

    RETURNING will normally return a query which would return Error 'query has no destination for result data' if you call it in plpgsql without using its returned result set.

提交回复
热议问题