I am using Database select connector in anypoint studio. This is the query I am using SELECT emp_id, emp_name, emp_status FROM employees
. Now there is no error but the response I receive is something like this (converted to json):
[
{
"EMP_ID": 2345336,
"EMP_NAME": "Dhananjay Pareek",
"EMP_STATUS": "Inactive"
},
{
"EMP_ID": 101,
"EMP_NAME": "emp1",
"EMP_STATUS": "active"
},
{
"EMP_ID": 122365,
"EMP_NAME": "Aram",
"EMP_STATUS": "Active"
},
{
"EMP_ID": 6666,
"EMP_NAME": "Rakim",
"EMP_STATUS": "Inactive"
},
{
"EMP_ID": 667676,
"EMP_NAME": "Kendrick",
"EMP_STATUS": "Active"
},
{
"EMP_ID": 7778,
"EMP_NAME": "Biggie",
"EMP_STATUS": "Inactive"
},
{
"EMP_ID": 102,
"EMP_NAME": "emp2",
"EMP_STATUS": "inactive"
},
{
"EMP_ID": 103,
"EMP_NAME": "emp3",
"EMP_STATUS": "active"
},
{
"EMP_ID": 104,
"EMP_NAME": "emp4",
"EMP_STATUS": "inactive"
},
{
"EMP_ID": 105,
"EMP_NAME": "emp5",
"EMP_STATUS": "active"
},
{
"EMP_ID": 106,
"EMP_NAME": "emp6",
"EMP_STATUS": "active"
},
{
"EMP_ID": 1012,
"EMP_NAME": "Drake",
"EMP_STATUS": "Active"
},
{
"EMP_ID": 3245,
"EMP_NAME": "Kendrick Lamar",
"EMP_STATUS": "Inactive"
},
{
"EMP_ID": 5897,
"EMP_NAME": "J. Cole",
"EMP_STATUS": "Active"
},
{
"EMP_ID": 1123,
"EMP_NAME": "Cardi B",
"EMP_STATUS": "Active"
},
{
"EMP_ID": 7458,
"EMP_NAME": "Lil Wayne",
"EMP_STATUS": "Inactive"
},
{
"EMP_ID": null,
"EMP_NAME": null,
"EMP_STATUS": null
},
{
"EMP_ID": null,
"EMP_NAME": null,
"EMP_STATUS": null
},
{
"EMP_ID": null,
"EMP_NAME": null,
"EMP_STATUS": null
},
{
"EMP_ID": null,
"EMP_NAME": null,
"EMP_STATUS": null
},
{
"EMP_ID": null,
"EMP_NAME": null,
"EMP_STATUS": null
},
{
"EMP_ID": null,
"EMP_NAME": null,
"EMP_STATUS": null
},
{
"EMP_ID": null,
"EMP_NAME": null,
"EMP_STATUS": null
},
{
"EMP_ID": null,
"EMP_NAME": null,
"EMP_STATUS": null
},
{
"EMP_ID": null,
"EMP_NAME": null,
"EMP_STATUS": null
},
{
"EMP_ID": null,
"EMP_NAME": null,
"EMP_STATUS": null
}
]
I am using Oracle database. 26 records are returned while I only have 16 records in the database. There are 10 extra records all with null field values as you can see above. I also debugged some projects that I made previously and the select connector in these projects is also behaving like this (all were working fine before). I tried using different versions of Database module, different jdbc drivers along with jdk8 and jdk 17 but nothing seems to work. I previously faced issues related to driver/version configurations, but this one just isn't letting me off the hook.
What could be the possible issue here?
What could be the possible issue here?
The issue is probably that you have 26 rows in the database and 10 of them contain NULL
values.
In Oracle, run:
SELECT *
FROM employees
WHERE emp_id IS NULL
AND emp_name IS NULL
AND emp_status IS NULL
It should return 10 rows with NULL
values for those columns.
If you do not want those 10 rows then use:
DELETE FROM employees
WHERE emp_id IS NULL
AND emp_name IS NULL
AND emp_status IS NULL
then COMMIT
the changes.
If you should always have non-null values in those columns then:
ALTER TABLE employees MODIFY (
emp_id NUMBER(10,0) NOT NULL,
emp_name VARCHAR2(200) NOT NULL,
emp_status VARCHAR2(10) NOT NULL
)
Note: Modify the data-types as appropriate.