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

[5.3] ORA-01438: value larger than specified precision allowed for this column.

Open johdougss opened this issue 8 years ago • 6 comments

Error:

  1. ORA-01438: value larger than specified precision allowed for this column.
  • The id column generated by migrate number (10)
  • If I increase the size (32) of the column the assigned value is 1971389988927 and not the id 25 image

image

In OracleProcessador.php If I change the code and return only PDO:PARAM_STR the insert works

private function getPdoType( $value ) {
      return PDO::PARAM_STR;
}

or convert values to string in bindValues

private function bindValues( &$values, $statement, $parameter ) {
		$count = count( $values );
		for ( $i = 0; $i < $count; $i++ ) {
			if ( is_object( $values[ $i ] ) ) {
				$values[ $i ] = (string)$values[ $i ];
			}
			if ( is_bool( $values[ $i ] ) ) {
				$values[ $i ] = (string)$values[ $i ];
			}
			if ( is_int( $values[ $i ] ) ) {
				$values[ $i ] = (string)$values[ $i ];
			}
			$type = $this->getPdoType( $values[ $i ] );
			$statement->bindParam( $parameter, $values[ $i ], $type );
			$parameter++;
		}
		return $parameter;
	}

But this is not the correct implementation. Is it missing any configuration in the database to accept the pdo typing?

Migration:

Schema::create( 'schedules', function ( Blueprint $table ) {
	$table->increments( 'id' );
	$table->string( 'name', 63 )->nullable();
} );

Table created: image

Create Sequence:

create sequence schedules_id_seq
minvalue 1
maxvalue 9999999999
start with 1
increment by 1
nocache
cycle;

Model:

class Schedule extends Model {

	protected $table = 'schedules';

	public $sequence = 'schedules_id_seq';

	protected $dates = [
		'updated_at',
		'created_at',
		'previous_planned_run',
		'previous_run',
		'next_planned_run',
	];

	protected $fillable = [
		'id',
		'name',
		'description',
		'command',
		'cron',
		'filename_log',
		'active',
		'updated_at',
		'created_at',
		'previous_planned_run',
		'previous_run',
		'next_planned_run',
	];

	protected $casts = [
		'active' => 'boolean',
	];
    ....

Save model:

$schedule = new Schedule();
$schedule->name = 'xx';
$schedule->save();

Query Generate

 insert into "SCHEDULES4" ("ACTIVE", "ID") values (?, ?) returning "ID" into ?
$binding =  [0,25,2] 

Composer.json:

"laravel/framework": "5.3.*",
    "yajra/laravel-oci8": "5.3.*"

php 5.6.21 extension - php_oci8_11g.dll - File version 5.6.24 Oracle 11.2.0.1.0

johdougss avatar Feb 01 '17 01:02 johdougss

I tried to replicate the issue on Laravel 5.4 and it's all working fine on my side. Will try to setup Laravel 5.3 when I had the chance. This might be an issue on 5.3. Thanks!

yajra avatar Feb 02 '17 03:02 yajra

BTW, if you can, please do not hesitate a PR for a possible fix if this is indeed a bug. Thanks!

yajra avatar Feb 02 '17 03:02 yajra

do you use zend server?

sciracioglu avatar Feb 17 '17 02:02 sciracioglu

Same error am also getting @johnathansantos found solution?

spsaravananct avatar Mar 22 '21 06:03 spsaravananct

I also got the same error https://github.com/yajra/laravel-oci8/issues/552

khactrung0902 avatar Sep 28 '21 07:09 khactrung0902

Solved by changing oci8 version from 2.0.10 to 2.0.8

khactrung0902 avatar Sep 29 '21 01:09 khactrung0902

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Dec 02 '22 02:12 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale.

github-actions[bot] avatar Dec 10 '22 02:12 github-actions[bot]