vendredi 11 septembre 2020

Oracle Query in Codeigniter giving ORA-01722 and ORA-01756

Im usually use mysql database in my website, but i trying to learn more about the oracle... My code working 2days ago, but right now its giving an error message such as ORA-number this is my database fields

KODE_GUDANG CHAR        
GUDANG      CHAR
LASTUPDATE  CHAR            
KODE_UNIT   CHAR            
NOMER_REKJURNAL CHAR            
KODE_GUDANG_KREDIT  CHAR            

this is my models for query

function getDataOneColumn($getCol, $table, $column, $id) {
    return $this->db->query("SELECT $getCol as val FROM $table WHERE $column = $id")->row_array();
  }

This is for my controller that giving an error : ORA-01722

 $this->data['no_rek'] = ($this->data['no_rek'] =='')?$this->m_dao->getDataOneColumn("NOMER_REKJURNAL","TBL_MASTER_GUDANG","KODE_GUDANG",$this->data['kode_gdg'])['VAL']:$this->data['no_rek'];

and after that i reading the docummentation, its means "You executed a SQL statement that tried to convert a string to a number"

i try to change my code to

 $this->data['no_rek'] = ($this->data['no_rek'] =='')?$this->m_dao->getDataOneColumn("NOMER_REKJURNAL","TBL_MASTER_GUDANG","KODE_GUDANG",'"'.$this->data['kode_gdg'])['VAL'].'"':"'".$this->data['no_rek']."'";

this one giving an other ORA error,ORA-01756. its means "You tried to execute a statement that contained a string that was not surrounded by two single quotes"

Can somebody tell me why my code getting an error after 2days ? And How to solve this error? thank you




Aucun commentaire:

Enregistrer un commentaire