Commit 5d056f69 authored by Gaetan Carabetta's avatar Gaetan Carabetta
Browse files

update json

parent 2ffbb9e0
...@@ -28,12 +28,22 @@ INSERT INTO animal VALUES ( ...@@ -28,12 +28,22 @@ INSERT INTO animal VALUES (
"medicaments":[ "medicaments":[
{ {
"nom": "LEVOTHYROX", "nom": "LEVOTHYROX",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 4 "quantité": 4
}
}, },
{ {
"nom": "DOLIPRANE", "nom": "DOLIPRANE",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 3 "quantité": 3
} }
}
] ]
}, },
{ {
...@@ -45,16 +55,31 @@ INSERT INTO animal VALUES ( ...@@ -45,16 +55,31 @@ INSERT INTO animal VALUES (
"medicaments":[ "medicaments":[
{ {
"nom": "LEVOTHYROX", "nom": "LEVOTHYROX",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 4 "quantité": 4
}
}, },
{ {
"nom": "DOLIPRANE", "nom": "DOLIPRANE",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 3 "quantité": 3
}
}, },
{ {
"nom": "LEVOTHYROX", "nom": "LEVOTHYROX",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 2 "quantité": 2
} }
}
] ]
} }
]', 1,'lapin'); ]', 1,'lapin');
...@@ -73,12 +98,22 @@ INSERT INTO animal VALUES ( ...@@ -73,12 +98,22 @@ INSERT INTO animal VALUES (
"medicaments":[ "medicaments":[
{ {
"nom": "IMODIUM", "nom": "IMODIUM",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 2 "quantité": 2
}
}, },
{ {
"nom": "FORLAX", "nom": "FORLAX",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 3 "quantité": 3
} }
}
] ]
} }
]', 2,'lapin'); ]', 2,'lapin');
...@@ -96,8 +131,13 @@ INSERT INTO animal VALUES ( ...@@ -96,8 +131,13 @@ INSERT INTO animal VALUES (
"medicaments":[ "medicaments":[
{ {
"nom": "PLAVIX", "nom": "PLAVIX",
"posologie":
{
"debut": "2019-06-17",
"duree": 10,
"quantité": 2 "quantité": 2
} }
}
] ]
} }
]', 3,'hamster'); ]', 3,'hamster');
/*
Exemple de requête pour récupérer des éléments
d'un tableau dans un tableau JSON
*/
select m->>'nom'
from animal a, json_array_elements(a.traitements) t, json_array_elements(t->'medicaments') m;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment