| 3417 | // |
| 3418 | |
| 3419 | static act* act_insert() |
| 3420 | { |
| 3421 | const TEXT* transaction = NULL; |
| 3422 | |
| 3423 | par_options(&transaction); |
| 3424 | |
| 3425 | if (MSC_match(KW_CURSOR)) |
| 3426 | return act_insert_blob(); |
| 3427 | |
| 3428 | if (!MSC_match(KW_INTO)) |
| 3429 | CPR_s_error("INTO"); |
| 3430 | |
| 3431 | gpre_req* request = MSC_request(REQ_insert); |
| 3432 | request->req_trans = transaction; |
| 3433 | gpre_ctx* context = SQE_context(request); |
| 3434 | |
| 3435 | int count = 0, count2 = 0; |
| 3436 | gpre_lls* fields = NULL; |
| 3437 | |
| 3438 | // Pick up a field list |
| 3439 | |
| 3440 | if (!MSC_match(KW_LEFT_PAREN)) |
| 3441 | { |
| 3442 | gpre_nod* list = MET_fields(context); |
| 3443 | count = list->nod_count; |
| 3444 | for (int i = 0; i < count; i++) |
| 3445 | MSC_push(list->nod_arg[i], &fields); |
| 3446 | } |
| 3447 | else |
| 3448 | { |
| 3449 | do { |
| 3450 | gpre_nod* node = SQE_field(request, false); |
| 3451 | if (node->nod_type == nod_array) |
| 3452 | { |
| 3453 | node->nod_type = nod_field; |
| 3454 | |
| 3455 | // Make sure no subscripts are specified |
| 3456 | |
| 3457 | if (node->nod_arg[1]) { |
| 3458 | PAR_error("Partial insert of arrays not permitted"); |
| 3459 | } |
| 3460 | } |
| 3461 | |
| 3462 | // Dialect 1 program may not insert new datatypes |
| 3463 | if ((SQL_DIALECT_V5 == gpreGlob.sw_sql_dialect) && nod_field == node->nod_type) |
| 3464 | { |
| 3465 | const USHORT field_dtype = ((ref*) (node->nod_arg[0]))->ref_field->fld_dtype; |
| 3466 | if (dtype_sql_date == field_dtype || dtype_sql_time == field_dtype || |
| 3467 | dtype_int64 == field_dtype) |
| 3468 | { |
| 3469 | SQL_dialect1_bad_type(field_dtype); |
| 3470 | } |
| 3471 | } |
| 3472 | |
| 3473 | MSC_push(node, &fields); |
| 3474 | count++; |
| 3475 | } while (MSC_match(KW_COMMA)); |
| 3476 |
no test coverage detected