TransWikia.com

Error: invalid input syntax for type integer

Stack Overflow Asked by HAMMAD ALI on November 7, 2021

I am using postgresql database. I am getting this error "invalid input syntax for type integer" while inserting data into table via express api but the same query is successfully run in pgAdmin.

const file = require('../../Pool');
const pool = file.pool;

const createClass= (req,res)=>{

    pool.query("insert into classes(class_name,school_id) values ( 'ICS' , (select id from schools where admin_id = 1))",[className,adminId],
        (err,result)=>{
            if(err){
                console.log('err');
                throw err
            }
            res.status(200).send({"isCreated":true})
        }
    )
}

module.exports = {
    createClass     
}

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP