I have a how to question regarding duplicate key in DB2 table
I have a how to question regarding duplicate key in DB2 table
When creating row in a DB2 table , if the key value already exists, Editor throws an error
<br/><b>Warning</b>: db2_execute(): Statement Execute Failed in <b>/www/seidenphp/htdocs/DataTables_Editor/lib/Database/Driver/Db2Query.php</b> on line <b>134</b><br/><br/><b>Warning</b>: db2_execute(): Duplicate key value specified. SQLCODE=-803 in <b>/www/seidenphp/htdocs/DataTables_Editor/lib/Database/Driver/Db2Query.php</b> on line <b>134</b><br/><br/><b>Warning</b>: db2_stmt_error(): Duplicate key value specified. SQLCODE=-803 in <b>/www/seidenphp/htdocs/DataTables_Editor/lib/Database/Driver/Db2Query.php</b> on line <b>137</b><br/>{
"fieldErrors": [],
"error": "DB2 SQL error = 23505",
"data": [],
"ipOpts": [],
"cancelled": [],
"debug": [
"Editor PHP libraries - version 2.3.2"
]
}
I would like to display a message to the user letting the know that a duplicate record was found in the DB2 table.
Looking for the most efficient to do this either from the ssp ->validator or JavaScript editor.on function.
Any examples or thoughts ?
Here is my ssp script
<?php
session_start();
date_default_timezone_set('America/Chicago'); // CDT
// DataTables PHP library
require( $_SERVER['DOCUMENT_ROOT']."/DataTables_Editor/lib/DataTables.php" );
// Alias Editor classes
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;
Editor::inst( $db, 'SCHEMA.TABLE', 'YYYYMMDATE')
->fields(
Field::inst('YYYYMMDATE')
->validator( Validate::notEmpty( ValidateOptions::inst()
->message( 'A Date is Required YYYYMM' )
) ),
Field::inst( 'VALUE' )
->validator( Validate::notEmpty( ValidateOptions::inst()
->message( 'Please enter a numeric decimal value, ie. 00.0' )
) ),
Field::inst( 'DIVIDEND' )
->validator( Validate::notEmpty( ValidateOptions::inst()
->message( 'Please enter a numeric decimal value, ie. 00.0' )
) )
)
->debug(true)
->process( $_POST )
->json();