[Microsoft][ODBC Driver 11 for SQL Server][SQL Server] SQLSTATE: 42000, CODE: 3980

735 Views Asked by At

What is the possible problem with my API service, when I executing a insert query into the SQL Server database using Zf2's TableGateway it always showing with an error:

SQLSTATE: 42000

Code: 3980

Message: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]The request failed to run because the batch is aborted, this can be caused by abort signal sent from client, or another request is running in the same session, which makes the session busy.

Here is my example of my code:

<?php
namespace Unilever\V1\Rest\RouteDetailSku;

use ZF\ApiProblem\ApiProblem;
use Zend\Db\TableGateway\TableGateway;;

class RouteDetailSkuMapper {
    protected $adapter;
    protected $table;
    function __construct($adapter) {
        $this->adapter = $adapter;
        $this->table = new TableGateway("route_detail_order", $this->adapter);
    }

    function save($data) {

        try{
           $this->table->insert((array) $data);
           $generatedData['data']  = $this->table->select((array) $data)->current();
            return new ApiProblem(201, "Success", "Route Detail SKU", "Create Route Detail SKU", (array) $generatedData);
        } catch(\Exception $e) {
            echo $e->getMessage();
        } catch(\RuntimeException $e){
            echo $e->getMessage();
        }
    }
}

This only showing on the INSERT but when doing the select query it is okay. How I can solve this?

0

There are 0 best solutions below