laravel-oci8 icon indicating copy to clipboard operation
laravel-oci8 copied to clipboard

Insert: Getting the Sequence Number

Open johnwswar opened this issue 5 years ago • 2 comments

I am using Laravel 7.x query builder to perform an insert statement, however, the Oracle database trigger automatically creates a sequence number. I want to do two things:

  1. get the sequence number that the database created.
  2. pass that sequence number via Ajax so I can perform a refresh.

public function store(Request $request)

{
   if ($request->ajax()) {

$insert = DB::table('test_table')->insert([

                'column1'=>$column1,
                'column2'=>$colum2
        ]);

return response()->json(array('message'=> $insert), 200); } }

  • Centos 7
  • PHP Version: 7.3.16
  • Laravel Version: 7.x
  • Laravel-OCI8 Version: 7

johnwswar avatar Sep 10 '20 17:09 johnwswar

Just fetch the next sequence value. See https://yajrabox.com/docs/laravel-oci8/master/sequence for ref.

yajra avatar Sep 11 '20 02:09 yajra

Just found out while working on #615 that there is a failing test for this scenario. Will try to fix on future release. Thanks!

yajra avatar Dec 08 '20 05:12 yajra