The identifier that starts with '***' is too long. Maximum length is 128.
The identifier that starts with '***' is too long. Maximum length is 128.
Error messages shown:
PDOException: SQLSTATE[42000]: [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]The identifier that starts with '(( CASE WHEN st.column= 0 THEN (st.column* (1 + (0.01 * tx.column))) ELSE st.epv1 END) / (1 + (0.01 * tx.column))) - st.column' is too long. Maximum length is 128.
Description of problem:
I'm having difficulties executing a query where it has complex fields, I leave the code and the error here.
`Editor::inst( $db, 'table tt', 'id' )
->readTable('table')
->field(
Field::inst( 'tt.column', 'ref' ),
Field::inst( 'tt.column', 'artigo' ),
Field::inst( 'tt.column', 'marca' ),
Field::inst( 'tt.column', 'id_fornecedor' ),
Field::inst( 'tt.column', 'fornecedor' ),
Field::inst( 'tt.column', 'preco_ponderado' ),
Field::inst( '(CASE WHEN tt.column = 1 THEN (tt.column / (1 + (0.01 * tx.column))) ELSE tt.column END)', 'PVP1' ),
Field::inst( '(CASE WHEN tt.column = 1 THEN (tt.column / (1 + (0.01 * tx.column))) ELSE tt.column END)', 'PVP2' ),
Field::inst( '(CASE WHEN tt.column = 1 THEN (tt.column / (1 + (0.01 * tx.column))) ELSE tt.column END)', 'PVP3' ),
Field::inst( '(CASE WHEN tt.column = 1 THEN (tt.column / (1 + (0.01 * tx.column))) ELSE tt.column END)', 'PVP4' ),
Field::inst( '(( CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / (1 + (0.01 * tx.column))) - tt.column', 'LUCRO1_0' ),
Field::inst( '(((CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / 1.05) / (1 + (0.01 * tx.column))) - tt.column', 'LUCRO1_5' ),
Field::inst( '(( CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / (1 + (0.01 * tx.column))) - tt.column', 'LUCRO2_0' ),
Field::inst( '(((CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / 1.10) / (1 + (0.01 * tx.column))) - tt.column', 'LUCRO2_10' ),
Field::inst( '(((CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / 1.15) / (1 + (0.01 * tx.column))) - tt.column', 'LUCRO2_15' ),
Field::inst( '(( CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / (1 + (0.01 * tx.column))) - tt.column', 'LUCRO3_0' ),
Field::inst( '(( CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / (1 + (0.01 * tx.column))) - tt.column', 'LUCRO4_0' ),
Field::inst( '(((CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / 1.10) / (1 + (0.01 * tx.column))) - tt.column', 'LUCRO4_10' ),
Field::inst( '(((CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / 1.15) / (1 + (0.01 * tx.column))) - tt.column', 'LUCRO4_15' ),
Field::inst( '(CASE WHEN tt.column = 0 THEN 0 ELSE ((((( CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / (1 + (0.01 * tx.column))) - tt.column) * 100) / (CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END)) END)', 'MARGEM1_0' ),
Field::inst( '(CASE WHEN tt.column = 0 THEN 0 ELSE ((((((CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / 1.05) / (1 + (0.01 * tx.column))) - tt.column) * 100) / (CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END)) END)', 'MARGEM1_5' ),
Field::inst( '(CASE WHEN tt.column = 0 THEN 0 ELSE ((((( CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / (1 + (0.01 * tx.column))) - tt.column) * 100) / (CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END)) END)', 'MARGEM2_0' ),
Field::inst( '(CASE WHEN tt.column = 0 THEN 0 ELSE ((((((CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / 1.10) / (1 + (0.01 * tx.column))) - tt.column) * 100) / (CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END)) END)', 'MARGEM2_10' ),
Field::inst( '(CASE WHEN tt.column = 0 THEN 0 ELSE ((((((CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / 1.15) / (1 + (0.01 * tx.column))) - tt.column) * 100) / (CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END)) END)', 'MARGEM2_15' ),
Field::inst( '(CASE WHEN tt.column = 0 THEN 0 ELSE ((((( CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / (1 + (0.01 * tx.column))) - tt.column) * 100) / (CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END)) END)', 'MARGEM3_0' ),
Field::inst( '(CASE WHEN tt.column = 0 THEN 0 ELSE ((((( CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / (1 + (0.01 * tx.column))) - tt.column) * 100) / (CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END)) END)', 'MARGEM4_0' ),
Field::inst( '(CASE WHEN tt.column = 0 THEN 0 ELSE ((((((CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / 1.10) / (1 + (0.01 * tx.column))) - tt.column) * 100) / (CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END)) END)', 'MARGEM4_10' ),
Field::inst( '(CASE WHEN tt.column = 0 THEN 0 ELSE ((((((CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END) / 1.15) / (1 + (0.01 * tx.column))) - tt.column) * 100) / (CASE WHEN tt.column = 0 THEN (tt.column * (1 + (0.01 * tx.column))) ELSE tt.column END)) END)', 'MARGEM4_15' )
)
->leftJoin( 'table tx', 'tx.column', '=', 'column' )
->tryCatch(false)
->debug(true)
->process($_POST)
->json();`