0

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`
})
9
  • Where is the rest of your stack trace? It will have a line number. Briefly reading your code the date in date = new Date(); is also undefined. Commented Jan 15, 2020 at 3:27
  • @BlueWater86 I added line number and the date also show value: 2020-01-15T03:31:08.486Z Commented Jan 15, 2020 at 3:32
  • That's not the line number. Commented Jan 15, 2020 at 3:39
  • You still haven't declared your 'date' variable. Commented Jan 15, 2020 at 3:39
  • 1
    There is a typo in ":entryOperator:entryDate" in the VALUES SQL clause, You are missing a comma. Commented Jan 15, 2020 at 6:50

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.