Search code examples
javascriptoracle-databasenode-oracledb

Error: ORA-01036: illegal variable name/number - NodeJS


I have created an API and want to insert data into the oracle database. But I received an error message "Error: ORA-01036: illegal variable name/number".I don't know what mistake I have made. Hope can help me solve this problem. Thank you in advance.

[Error: ORA-01036: illegal variable name/number] { errorNum: 1036, offset: 0 }

//post 
async function AddData(form){

     console.log(form);

     let Status = {
          status:_const.MSG_STATUS_ERROR,
          message:_const.MSG_STATUS_ERROR,
          info:null
     };


     let connection;
     let date = new Date();

     try{
          connection = await oracledb.getConnection(dbconfig);

          const result = await connection.execute(
               `INSERT INTO EIS_PANTAURUM 
               (    
                    PAN_ZONRUMPUT,PAN_TAMRUMPUT,PAN_BULANPTAU,PAN_MASAPNTAU,
                    PAN_STATUSKOD,PAN_CATATANSS,PAN_SEBLUMPIC,PAN_SLEPASPIC,
                    PAN_SEMASAPIC,PAN_ENTRYOPER,PAN_ENTRYDATE,PAN_TIMESAMPM,
                    PAN_PUSINGANS,PAN_TAHUNRPUT
               )
               VALUES
               (    :zon,:taman,:bulan,:masa,
                    :status,:catatan,:sebelumPic,:selepasPic,
                    :semasaPic,:entryOperator:entryDate,:timeAMPM,
                    :pusingan,:tahun
               )`,{zon:form.zon,taman:form.taman,bulan:form.bulan,masa:form.masa
                    ,status:form.status,catatan:form.catatan,sebelumPic:"Empty.jpg",selepasPic:"Empty.jpg"
                    ,semasaPic:"Empty.jpg",entryOperator:form.entryOperator,entryDate:date,timeAMPM:form.timeAMPM
                    ,pusingan:form.pusingan,tahun:form.tahun}
          );

          Status.status = _const.MSG_STATUS_SUCCESS;
          Status.message = _const.MSG_STATUS_SUCCESS;
          Status.info = result.rowsAffected;     


     }catch(err){
          console.error(err);
          Status.message = err;
          return Status;

     }finally{
          if(connection){
               try{
                    await connection.close();
               }catch(err){
                    console.error(err);
                    Status.message = err;
                    return Status;
               }
          }
     }

     return Status;

}

router.post('/api/AddData/:zon/:syarikat/:alamat_syarikat/'+
          ':nama_penyelia/:taman/:bulan/:tahun/:masa/:timeAMPM/:pusingan/:status/:catatan/:state/'+
          ':entryOperator',(req,res) =>{

     AddData(req.params).then(function(value){
          console.log(value);
          res.send(value);
     })`enter code here`
})

Solution

  • I believe there is a comma missing in

    :entryOperator:entryDate
    

    It has to be the following here

    :entryOperator,:entryDate
    

    I'd recommend you to use spaces after each comma. Such a habit helps you to avoid errors like that one