I am using PostgreSQL functions instead of query the problem facing is the errror. The errors are driven as result here the code follows
router.post('/insert_update_employee', (req, res) => { debugger; data = req.body; pool.connect((err, client, done) => { const query = 'SELECT insert_update_employee($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12) '; const values = [data.ID, data.Name, data.DOB, data.ContactNo, data.EmailAddress, data.SupervisorID, data.PositionID, data.HireDate, data.IsSupervisor, data.ImageUrl, data.UserName, data.IsUpdate]; client.query(query, values, (err, result) => { done(); if (err) { debugger; res.status(400).json({ err }); } debugger; res.status(202).send({ status: 'SUccessful', result: result.rows[0] }); }); }); });
Hi Thomson, sorry for the late reply. Can you explain a little bit further what the problem is? 😉
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I am using PostgreSQL functions instead of query the problem facing is the errror. The errors are driven as result here the code follows
router.post('/insert_update_employee', (req, res) => {
debugger;
data = req.body;
pool.connect((err, client, done) => {
const query = 'SELECT insert_update_employee($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12) ';
const values = [data.ID, data.Name, data.DOB, data.ContactNo, data.EmailAddress, data.SupervisorID, data.PositionID, data.HireDate, data.IsSupervisor, data.ImageUrl, data.UserName, data.IsUpdate];
client.query(query, values, (err, result) => {
done();
if (err) {
debugger;
res.status(400).json({ err });
}
debugger;
res.status(202).send({
status: 'SUccessful',
result: result.rows[0]
});
});
});
});
Hi Thomson, sorry for the late reply. Can you explain a little bit further what the problem is? 😉