Oracle - insert and edit problem on joined table
Oracle - insert and edit problem on joined table
Hi all,
i have a problem with one of my tables. It has joined data on an oracle-db, when trying to edit a row or insert a new one.
Here are my codes:
PHP
<?php
/*
* Editor server script for DB table STG_TAB_ARTIKEL
* Created by http://editor.datatables.net/generator
*/
// DataTables PHP library and database connection
include( "lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'STG_TAB_ARTIKEL a', 'a.PK_ARTIKEL_ID' )
->debug(true)
->fields(
Field::inst( 'a.ARTNR' )
->validator( 'Validate::unique' )
->validator( 'Validate::required' )
->validator( 'Validate::numeric' ),
Field::inst( 'a.FK_STG_TAB_ARTKAT' )
->options( Options::inst()
->table( 'STG_TAB_ARTIKELKATEGORIE' )
->value( 'ARTKATNR' )
->label( 'ARTKAT' )
)
->validator( 'Validate::dbValues' ),
Field::inst( 'a.ARTBEZ' )
->validator( 'Validate::notEmpty' ),
Field::inst( 'a.ARTMAß' ),
Field::inst( 'ak.ARTKAT' )
)
->leftJoin( 'STG_TAB_ARTIKELKATEGORIE ak', 'ak.ARTKATNR', '=', 'a.FK_STG_TAB_ARTKAT')
->process( $_POST )
->json();
<?php
>
```
?>
JS
/*
* Editor client script for DB table STG_TAB_KUNDEN
* Created by http://editor.datatables.net/generator
*/
(function($){
$(document).ready(function() {
var editor = new $.fn.dataTable.Editor( {
ajax: 'sources/table.STG_TAB_ARTIKEL.php',
table: '#STG_TAB_ARTIKEL',
fields: [
{
"label": "Artikel:",
"name": "a.ARTNR"
},
{
"label": "Artikelkategorie:",
"name": "a.FK_STG_TAB_ARTKAT",
"type": "select",
"placeholder" : "Bitte Kategorie auswählen.."
},
{
"label": "Bezeichnung:",
"name": "a.ARTBEZ"
},
{
"label": "Maße:",
"name": "a.ARTMAß"
}
]
} );
var table = $('#STG_TAB_ARTIKEL').DataTable( {
dom: 'Bfrtip',
ajax: 'sources/table.STG_TAB_ARTIKEL.php',
serverSide: true,
scrollY: '70vh',
scrollCollapse: true,
paging: false,
cache: true,
columns: [
{
"data": "a.ARTNR"
},
{
"data": "ak.ARTKAT"
},
{
"data": "a.ARTBEZ"
},
{
"data": "a.ARTMAß"
}
],
select: "single",
lengthChange: false,
buttons: [
{ extend: 'create', editor: editor }
,{ extend: 'edit', editor: editor }
]
} );
} );
}(jQuery));
```
On debbuging the data-Header seems correct:
data[row_5760][a][ARTNR]:-2
data[row_5760][a][FK_STG_TAB_ARTKAT]:23
data[row_5760][a][ARTBEZ]:HTV - Einweg
data[row_5760][a][ARTMAß]:0x0
But on the debugSql-array on Preview Page doesn't start an update:
(see attachment) [2]query: SELECT a.PK_ARTIKEL_ID as "a.PK_ARTIKEL_ID", a.ARTNR as "a.ARTNR", a.FK_STG_TAB_ARTKAT as "a.FK_STG_TAB_ARTKAT", a.ARTBEZ as "a.ARTBEZ", a.ARTMAß as "a.ARTMAß", ak.ARTKAT as "ak.ARTKAT" FROM STG_TAB_ARTIKEL a LEFT JOIN STG_TAB_ARTIKELKATEGORIE ak ON ak.ARTKATNR = a.FK_STG_TAB_ARTKAT WHERE a.PK_ARTIKEL_ID = :where_0
Don't know why it isn't working, i have another table w/o the leftJoin() param which is working perfectly.
Looking forward to any help!
Thanks in advance
Br Toni
Replies
Hi,
Could you clarify in what way it isn't working please? Or specifically what happens a the client-side? You click submit and then? Does the Editor form disappear, or does it stay where it is?
Any information shown in your server's error log?
Thanks,
Allan
Hi Allan,
the Editor form disappears after clicking submit and acts like it has done everything as expected. It also refreshes the data. But no insert nor update statement on use of the Insert / Edit Button is triggered.
The debugSql Array shows no insert/update statement, i hope i understand this array correctly, because i think this is the result of the whole db-communication, isn't it?
I can't find any errors on the server's log.
Br Toni
It should be yes.
Are you able to give me a link to the page so I can attempt to debug the issue please?
Thanks,
Allan
Hi Alan,
i will send you a Teamviewer for debugging.
Thanks in Advance,
Toni
Hi Toni,
Could you try the attached Query.php for the Oracle driver in Editor please? It won't solve any issues as such, but it does include better error handling. So if there is an SQL error that will be correctly reported now.
Thanks,
Allan
Hi Allan,
thank you really much! It seems that i have trouble with the name of a coloumn.. Someone thought it was a good idea to use special characters like "ß" for the column.
On the initialization datatables is sending this as "?" to the db. So there is my error i guess
Do I have any chance of getting it fixed by editing datatables or do i have to edit the database itself?
(There is a big process flow behind the table which causes a lot of time to edit..)
Again - thank you really much for the help
Toni
Could you have a look at what DataTables is sending to the server using the browser's dev tools? That part at least should really support UTF-8. I'm not entirely sure what character set Oracle expects on its interface - I would have assumed UTF-8.
Allan
Hi Allan,
well there is no encoding on the headers, as far as i can see. Or do I look in the wrong place?
Teamviewer would be up again, if you want to look for yourself.
Thank you,
Toni
It might be worth having a look at zajc's last post in this thread which suggests a possible fix. It sounds like it might be the same issue you are running into.
Allan
Hi Allan,
I did the change on the connect with the charset parameter - now it is showing the data as expected and I have no more problem with the letter.
Unfortunately, the edit button does continue to select data from the db and does not try to update it.
debugSql is showing only selects as statements.
Thank you for your help,
Toni
Hi Allan,
the problem still exists.
We get our data as exprected. Everything is showing up correct.
But we can't create new entries or edit/delete existing entries.
If i try to delete an entry, the entry will no be showed in the datatable till i refresh the page.
I got no errors on client or server.
If i build this without
leftjoin()
and only show the fielda.FK_STG_TAB_ARTKAT
it works.PHP
Debug output on edit.
Thanks for your help.
Greetings
And if i try to delete i don't get any debug...
Greetings
Found a solution.
I'm now using Mjoin instead of leftjoin and everything works like expected.
PHP
Thanks for your support
Greetings
Hi Johann,
Could you let me know what version of the libraries you are using? I released 1.6.5 yesterday afternoon which I believe should address this issue. Assuming I'm correct, it is being caused by the use of the alias in the table name, which the libraries weren't correctly handling without an
as
which of course Oracle doesn't support.Allan