yajra / laravel-oci8

Oracle DB driver for Laravel via OCI8
https://yajrabox.com/docs/laravel-oci8
MIT License
832 stars 237 forks source link

Answer #34

Closed monkhsaikhan closed 10 years ago

monkhsaikhan commented 10 years ago

Is working table relation correctly? I have a problem.

First $ php artisan migrate

Migration table created successfully. [Illuminate\Database\QueryException] Error Code : 955 Error Message : ORA-00955: name is already used by an existing object Position : 13 Statement : create index form_question_get_valuevalue on form_question_get_value ( value_type ) (SQL: create index form_question_get_valuevalue on form_question_get_value ( value_type ))

[yajra\Pdo\Oci8\Exceptions\SqlException] Error Code : 955 Error Message : ORA-00955: name is already used by an existing object Position : 13 Statement : create index form_question_get_valuevalue on form_question_get_value ( value_type )

migrate [--bench[="..."]] [--database[="..."]] [--force] [--path[="..."]] [--package[="..."]] [--pretend] [--seed]

After $ php artisan migrate

[Illuminate\Database\QueryException] Error Code : 955 Error Message : ORA-00955: name is already used by an existing object Position : 13 Statement : create table form_question_get_value ( id number(10,0) not null, question_id number(10,0) not null, caption varchar2(255) null, value number(10,0) not null, value_type number(10,0) not null, created_at timestamp default CURRENT_TIMESTAMP not null, updated_at timestamp default CURRENT_TIMESTAMP not null, constraint form_question_get_value_id_pri primary key ( id ) ) (SQL: create table form_question_get_value ( id number(10,0) not null, question_id number(10,0) not null, caption varchar2(255) null, value number(10,0) not null, value_type number(10,0) not null, created_at timestamp default CURRENT_TIMESTAMP not null, updated_at timestamp default CURRENT_TIMESTAMP not null, constraint form_question_get_value_id_pri primary key ( id ) ))

[yajra\Pdo\Oci8\Exceptions\SqlException] Error Code : 955 Error Message : ORA-00955: name is already used by an existing object Position : 13 Statement : create table form_question_get_value ( id number(10,0) not null, question_id number(10,0) not null, caption varchar2(255) null, value number(10,0) not null, value_type number(10,0) not null, created_at timestamp default CURRENT_TIMESTAMP not null, updated_at timestamp default CURRENT_TIMESTAMP not null, constraint form_question_get_value_id_pri primary key ( id ) )

migrate [--bench[="..."]] [--database[="..."]] [--force] [--path[="..."]] [--package[="..."]] [--pretend] [--seed]

yajra commented 10 years ago

Yes, table relations are working properly.

Based on you errors above, it appears that you are using too long index name or you are using a table name that is too long which makes index name reached the limit of 30 chars. I suggest you add specific name to your index too avoid those errors. Note: Oracle only allows object names up to 30 chars.

$table->integer('id')-index('index_name');

In addition, notice the generated index name form_question_get_value_value_. Proper index name generated by Schema builder should end with _index. This does indicates that you do indeed have a long table name.

monkhsaikhan commented 10 years ago

I'm sorry! I remove all index from my migration classes. But i have this problem. How to fix this problem?

$ php artisan migrate Migration table created successfully.

[Illuminate\Database\QueryException] Error Code : 904 Error Message : ORA-00904: : invalid identifier Position : 111 Statement : create table request ( id number(10,0) not null, form_id number(10,0) not null, user_id number(10,0) not null, comment clob null, ipaddress varchar2(255) null, macaddress varchar2(255) null, tackling clob null, confirmation clob null, confirm_user_id number(10,0) not null, confirm_date date null, withenddate number(10,0) not null, enddate date null, request_status_id number(10,0) not null, created_at date null, updated_at date null, constraint request_id_primary primary key ( id ) ) (SQL: create table request ( id number(10,0) not null, form_id number(10,0) not null, user_id number(10,0) not null, comment clob null, ipaddress varchar2(255) null, macaddress varchar2(255) null, tackling clob null, confirmation clob null, confirm_user_id number(10,0) not null, confirm_date date null, withenddate number(10,0) not null, enddate date null, request_status_id number(10,0) not null, created_at date null, updated_at date null, constraint request_id_primary primary key ( id ) ))

[yajra\Pdo\Oci8\Exceptions\SqlException] Error Code : 904 Error Message : ORA-00904: : invalid identifier Position : 111 Statement : create table request ( id number(10,0) not null, form_id number(10,0) not null, user_id number(10,0) not null, comment clob null, ipaddress varchar2(255) null, macaddress varchar2(255) null, tackling clob null, confirmation clob null, confirm_user_id number(10,0) not null, confirm_date date null, withenddate number(10,0) not null, enddate date null, request_status_id number(10,0) not null, created_at date null, updated_at date null, constraint request_id_primary primary key ( id ) )

migrate [--bench[="..."]] [--database[="..."]] [--force] [--path[="..."]] [--package[="..."]] [--pretend] [--seed]

yajra commented 10 years ago

It seems that comment field name is not allowed because it is a reserved name on Oracle. If you really want to use that field name, enclose it with double quote.

$table->text('"comment"');

Else, just rename your comment field to something else. ^_^.

monkhsaikhan commented 10 years ago

Sorry one answer again! Is it working properly on Oracle Database 12c? My web server is Sentos 6.5. Database server is Oracle Database 12c. But i have one problem.

[InvalidArgumentException] Unsupported driver [pdo-via-oci8]

My database config:

'oracle' => array( 'driver' => 'pdo-via-oci8', 'host' => 'localhost', 'port' => '1521', 'database' => 'mydatabase', 'username' => 'myusername', 'password' => 'mypassword', 'prefix' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci' )

It is working properly on my local computer. My local database server is Oracle Database 11G.

yajra commented 10 years ago

Not really sure on Oracle 12c coz I don't have it. I only use version 10 and 11. But most probably it would work too.

For the unsupported driver, have you properly installed the package on config file? https://github.com/yajra/laravel-oci8#installation

Check also if your loading the correct config file. You might be using a local environment or something.