0

This is the function I use to insert a new user into the database:

public function store_user(Request $request){
    $user = new User();      

    $user->id_user = "999/11"; // this is the problem      

    $user->name= $request->input('user_name');
    $user->last_name= $request->input('last_name');
    $user->save();
    return redirect('/users');
}

Every time I got this error

Yajra\Pdo\Oci8\Exceptions\Oci8Exception Error Code : 1722 Error Message : ORA-01722: invalid number Position : 100 Statement : insert into "users" ("ID_USER", "UPDATED_AT", "CREATED_AT") values (:p0, :p1, :p2) returning "ID_USER" into :p3 Bindings : [999/11,2020-10-27 10:18:03,2020-10-27 10:18:03,0]

Raghav Garg
  • 3,601
  • 2
  • 23
  • 32
Jon
  • 57
  • 3
  • 11
  • what is datatype of `id_user ` column in database ? it should not be integer – Kamlesh Paul Oct 27 '20 at 10:37
  • VARCHAR2(8 BYTE) – Jon Oct 27 '20 at 10:38
  • then why it is showing `invalid number` i think you need to try with normal int is it working or not – Kamlesh Paul Oct 27 '20 at 10:41
  • The database is pre-existing, I can't change anything. id_user is varchar(8byte). id_user is composed of three things = number(represent departement) + / + (num of user). – Jon Oct 27 '20 at 10:49
  • can you please confirm if this is the full error stack trace? – Raghav Garg Oct 27 '20 at 10:52
  • Yajra\Pdo\Oci8\Exceptions\Oci8Exception Error Code : 1722 Error Message : ORA-01722: invalid number Position : 100 Statement : insert into "users" ("ID_USER", "UPDATED_AT", "CREATED_AT") values (:p0, :p1, :p2) returning "ID_USER" into :p3 Bindings : [999/11,2020-10-27 10:18:03,2020-10-27 10:18:03,0] – Jon Oct 27 '20 at 10:57
  • maybe helpful https://stackoverflow.com/questions/12549029/sql-error-ora-01722-invalid-number – Raghav Garg Oct 27 '20 at 11:03
  • can you please try with `$user->id_user = "string99";` and share if it is working or not? – Raghav Garg Oct 27 '20 at 11:04
  • No. it does not work: Yajra\Pdo\Oci8\Exceptions\Oci8Exception Error Code : 1722 Error Message : ORA-01722: invalid number Position : 100 Statement : insert into "UTIL_PARQUET" ("ID_USER", "UPDATED_AT", "CREATED_AT") values (:p0, :p1, :p2) returning "ID_USER" into :p3 Bindings : [/999/11,2020-10-27 11:09:50,2020-10-27 11:09:50,0] – Jon Oct 27 '20 at 11:10
  • Yajra\Pdo\Oci8\Exceptions\Oci8Exception Error Code : 1722 Error Message : ORA-01722: invalid number Position : 100 Statement : insert into "UTIL_PARQUET" ("ID_USER", "UPDATED_AT", "CREATED_AT") values (:p0, :p1, :p2) returning "ID_USER" into :p3 Bindings : [string99,2020-10-27 11:11:38,2020-10-27 11:11:38,0] – Jon Oct 27 '20 at 11:12

1 Answers1

0

whats is (id_user) type in database ?

If it is int, you can not enter. You must change its type to string