/ MakeInsert: make the Insert statement used with JDBC connection. */ /
| 375 | /* MakeInsert: make the Insert statement used with JDBC connection. */ |
| 376 | /***********************************************************************/ |
| 377 | bool TDBJDBC::MakeInsert(PGLOBAL g) |
| 378 | { |
| 379 | PCSZ schmp = NULL; |
| 380 | char *catp = NULL, buf[NAM_LEN * 3]; |
| 381 | int len = 0; |
| 382 | uint pos; |
| 383 | bool b = false; |
| 384 | // PTABLE tablep = To_Table; |
| 385 | PCOL colp; |
| 386 | |
| 387 | for (colp = Columns; colp; colp = colp->GetNext()) |
| 388 | if (colp->IsSpecial()) { |
| 389 | safe_strcpy(g->Message, sizeof(g->Message), "No JDBC special columns"); |
| 390 | return true; |
| 391 | } else { |
| 392 | // Column name can be encoded in UTF-8 |
| 393 | Decode(colp->GetName(), buf, sizeof(buf)); |
| 394 | len += (strlen(buf) + 6); // comma + quotes + valist |
| 395 | ((PEXTCOL)colp)->SetRank(++Nparm); |
| 396 | } // endif colp |
| 397 | |
| 398 | // Below 32 is enough to contain the fixed part of the query |
| 399 | if (Catalog && *Catalog) |
| 400 | catp = Catalog; |
| 401 | |
| 402 | if (catp) |
| 403 | len += strlen(catp) + 1; |
| 404 | |
| 405 | //if (tablep->GetSchema()) |
| 406 | // schmp = (char*)tablep->GetSchema(); |
| 407 | //else |
| 408 | if (Schema && *Schema) |
| 409 | schmp = Schema; |
| 410 | |
| 411 | if (schmp) |
| 412 | len += strlen(schmp) + 1; |
| 413 | |
| 414 | // Table name can be encoded in UTF-8 |
| 415 | Decode(TableName, buf, sizeof(buf)); |
| 416 | len += (strlen(buf) + 32); |
| 417 | Query = new(g)STRING(g, len, "INSERT INTO "); |
| 418 | |
| 419 | if (catp) { |
| 420 | Query->Append(catp); |
| 421 | |
| 422 | if (schmp) { |
| 423 | Query->Append('.'); |
| 424 | Query->Append(schmp); |
| 425 | } // endif schmp |
| 426 | |
| 427 | Query->Append('.'); |
| 428 | } else if (schmp) { |
| 429 | Query->Append(schmp); |
| 430 | Query->Append('.'); |
| 431 | } // endif schmp |
| 432 | |
| 433 | if (Quote) { |
| 434 | // Put table name between identifier quotes in case in contains blanks |
nothing calls this directly
no test coverage detected