Editor 2.0.0 does not return the new created row. (Oracle Db)

Editor 2.0.0 does not return the new created row. (Oracle Db)

cmezacmeza Posts: 4Questions: 1Answers: 0

datatables editor 2.0.0 does not return the new created row. (Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production)

{
"data": [],
"debug": [
{
"query": "INSERT INTO \"AEC_PAUTAS\" ( \"NOMBRE_DE_PAUTA\", \"DESCRIPCION_DE_PAUTA\", \"USUA_USUARIO\" ) VALUES ( :NOMBRE_DE_PAUTA, :DESCRIPCION_DE_PAUTA, :USUA_USUARIO ) RETURNING \"ID\" INTO :editor_pkey_value",
"bindings": [
{
"name": ":NOMBRE_DE_PAUTA",
"value": "sdfsdf",
"type": null
},
{
"name": ":DESCRIPCION_DE_PAUTA",
"value": "sdfsdfsdfsdf",
"type": null
},
{
"name": ":USUA_USUARIO",
"value": "christian.meza",
"type": null
}
]
},
{
"query": "SELECT \"ID\" \"ID\", \"NOMBRE_DE_PAUTA\" \"NOMBRE_DE_PAUTA\", \"DESCRIPCION_DE_PAUTA\" \"DESCRIPCION_DE_PAUTA\", \"FECHA_CREACION\" \"FECHA_CREACION\", \"ESTADO\" \"ESTADO\", \"VIGENTE\" \"VIGENTE\", \"USUA_USUARIO\" \"USUA_USUARIO\" FROM \"AEC_PAUTAS\" WHERE \"ID\" = :where_0 ",
"bindings": [
{
"name": ":where_0",
"value": "",
"type": null
}
]
}
]
}

Replies

  • allanallan Posts: 63,210Questions: 1Answers: 10,415 Site admin

    Looks like the primary key value wasn't read (note the value: '' in the binding for the SELECT query).

    What's the schema for your table please?

    Allan

  • cmezacmeza Posts: 4Questions: 1Answers: 0
    edited August 2023

    Hi Allan, I have created the table like this

    CREATE TABLE AEC_PAUTAS (
      ID INT GENERATED ALWAYS AS IDENTITY START WITH 1 INCREMENT BY 1 PRIMARY KEY,
      NOMBRE_DE_PAUTA VARCHAR2(250),
      DESCRIPCION_DE_PAUTA VARCHAR2(250),
      FECHA_CREACION TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      ESTADO NUMBER(1) DEFAULT 0,
      VIGENTE NUMBER(1) DEFAULT 1,
      PLANTILLA VARCHAR2(250),
      USUA_USUARIO VARCHAR(250) 
    );
    

    and this is server script

    use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Mjoin,
        DataTables\Editor\Options,
        DataTables\Editor\Upload,
        DataTables\Editor\Validate,
        DataTables\Editor\ValidateOptions;
     
        Editor::inst( $db, 'AEC_PAUTAS', 'ID' )
            ->fields(
                Field::inst( 'ID' ),
                Field::inst( 'NOMBRE_DE_PAUTA' )
                    ->validator( Validate::notEmpty( ValidateOptions::inst()
                        ->message($AecConfig['forms']['requiredField'])  
                    ) ),
                Field::inst( 'DESCRIPCION_DE_PAUTA' )
                    ->validator( Validate::notEmpty( ValidateOptions::inst()
                        ->message($AecConfig['forms']['requiredField'])  
                    ) ),
                Field::inst( 'FECHA_CREACION' ),
                Field::inst( 'ESTADO' ),
                Field::inst( 'VIGENTE' ),
                Field::inst( 'USUA_USUARIO' )
                    ->setValue( $_SESSION['usu_usuario'] )
            )
            ->debug(true)
            ->process( $_POST )
            ->json();
    

    Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • allanallan Posts: 63,210Questions: 1Answers: 10,415 Site admin

    Field::inst( 'ID' )

    Might be the issue. Could you add:

    Field::inst( 'ID' )->set(false)
    

    I presume that you don't want to allow the user to write to that field :). Moveover, if you don't need them to see it either, then just drop that line altogether.

    Allan

  • cmezacmeza Posts: 4Questions: 1Answers: 0

    Thanks Allan!

  • allanallan Posts: 63,210Questions: 1Answers: 10,415 Site admin

    Did that do it?

    Allan

Sign In or Register to comment.