I have json from another system, how to store in oracle database? I dont mind if using while or for or what ever, i only hope can store in database in 4 rows without null line as null line provided by another system. I already refer to many question but not find similar case data like mine.
This is then json example
{
"ErrorCode": "00",
"ErrorMessage": "",
"ServiceList": {
"ServiceDetail": [
{
"Service_name": [
"LTE_DATA_PRI_1",
"LTE_ONM_PRI_2"
],
"AVLAN": [
"LTE_DATA_PRI_SITE_1",
"LTE_DATA_PRI_SITE_2"
],
"IpAddress": [
"192.168.1/20",
"192.168.2/20"
],
"AggPort": [
"GigabitEthernet 1/1/10.1000",
"GigabitEthernet 1/1/10.1001"
]
},
"\r\n",
"\r\n",
{
"Service_name": [
"LTE_DATA_SEC_1",
"LTE_ONM_SEC_2"
],
"AVLAN": [
"LTE_DATA_SEC_SITE_1",
"LTE_DATA_SEC_SITE_2"
],
"IpAddress": [
"192.168.3/20",
"192.168.4/20"
],
"AggPort": [
"GigabitEthernet 1/1/10.1003",
"GigabitEthernet 1/1/10.1004"
]
},
"\r\n",
"\r\n"
]
}
}
expected display or store in database
below is my code in php file but it only save the primary
$i = 0;
$x = 0;
$arrayLength = count($array['ServiceList']['ServiceDetail']);
while ($x < $arrayLength)
{
$arrayLength2 = count($array['ServiceList']['ServiceDetail'][$x]['AVLAN']);
while ($i < $arrayLength2)
{
$AVLAN1 = $array['ServiceList']['ServiceDetail'][$x]['AVLAN'];
if ( $AVLAN1 !== null){
$p_avlan = $array['ServiceList']['ServiceDetail'][$x]['AVLAN'][$i];
$p_agg_port = $array['ServiceList']['ServiceDetail'][$x]['AggPort'][$i];
$p_ip_address = $array['ServiceList']['ServiceDetail'][$x]['IpAddress'][$i];
$p_service_name = $array['ServiceList']['ServiceDetail'][$x]['Service_name'][$i];
// sql procedure here //
$i++;
}
} // while 2
$x++;
} // while 1