PostgreSQL La base de donnees la plus sophistiquee au monde.

Forums PostgreSQL.fr

Le forum officiel de la communauté francophone de PostgreSQL

Vous n'êtes pas identifié(e).

#1 PL/pgSQL » multi update in one query jsonb postgres » 25/07/2022 10:34:44

R00t_Killer
Réponses : 0

I want to modify color and title with same data for specified items with this keys {0024dd81-db96-4a87-863b-e6ca9dd69d91,0024dd81-db96-4a87-863b-e6ca9dd69d92,0024dd81-db96-4a87-863b-e6ca9dd69d93} in one query the result must be like this all in one query
````
{
  "designation": "test"
  "items": {
    "0024dd81-db96-4a87-863b-e6ca9dd69d90": {
      "id": 71,
      "color": "#FFFFFF",
      "title": "item1",
    },
  "0024dd81-db96-4a87-863b-e6ca9dd69d91": {
      "id": 72,
      "color": "#FFFFFF",
      "title": "item2",
    },
    "0024dd81-db96-4a87-863b-e6ca9dd69d92": {
      "id": 73,
      "color": "#FFFFFF",
      "title": "item3",
    },
    "0024dd81-db96-4a87-863b-e6ca9dd69d93": {
      "id": 74,
      "color": "#FFFFFF",
      "title": "item4",
    }
  }
}
````

result must me like this :

```


{
  "designation": "test"
  "items": {
    "0024dd81-db96-4a87-863b-e6ca9dd69d90": {
      "id": 71,
      "color": "#FFFFFF",
      "title": "item1",
    },
  "0024dd81-db96-4a87-863b-e6ca9dd69d91": {
      "id": 72,
      "color": "#FFFFFF",
      "title": "item2",
    },
    "0024dd81-db96-4a87-863b-e6ca9dd69d92": {
      "id": 73,
      "color": "#FFFFFF",
      "title": "item3",
    },
    "0024dd81-db96-4a87-863b-e6ca9dd69d93": {
      "id": 74,
      "color": "#FFFFFF",
      "title": "item4",
    }
  }
}
{
  "designation": "test"
  "items": {
   "items": {
    "0024dd81-db96-4a87-863b-e6ca9dd69d90": {
      "id": 71,
      "color": "#FFFFFF",
      "title": "item1",
    },
  "0024dd81-db96-4a87-863b-e6ca9dd69d91": {
      "id": 72,
      "color": "#FFFFFF",
      "title": "updated",
    },
    "0024dd81-db96-4a87-863b-e6ca9dd69d92": {
      "id": 73,
      "color": "#FFFFFF",
      "title": "updated",
    },
    "0024dd81-db96-4a87-863b-e6ca9dd69d93": {
      "id": 74,
      "color": "#FFFFFF",
      "title": "updated",
    }
  }
}

```

Pied de page des forums

Propulsé par FluxBB