/ SetBuffer: prepare a column block for write operation. */ /
| 769 | /* SetBuffer: prepare a column block for write operation. */ |
| 770 | /***********************************************************************/ |
| 771 | bool EXTCOL::SetBuffer(PGLOBAL g, PVAL value, bool ok, bool check) |
| 772 | { |
| 773 | if (!(To_Val = value)) { |
| 774 | snprintf(g->Message, sizeof(g->Message), MSG(VALUE_ERROR), Name); |
| 775 | return true; |
| 776 | } else if (Buf_Type == value->GetType()) { |
| 777 | // Values are of the (good) column type |
| 778 | if (Buf_Type == TYPE_DATE) { |
| 779 | // If any of the date values is formatted |
| 780 | // output format must be set for the receiving table |
| 781 | if (GetDomain() || ((DTVAL *)value)->IsFormatted()) |
| 782 | goto newval; // This will make a new value; |
| 783 | |
| 784 | } else if (Buf_Type == TYPE_DOUBLE) |
| 785 | // Float values must be written with the correct (column) precision |
| 786 | // Note: maybe this should be forced by ShowValue instead of this ? |
| 787 | value->SetPrec(GetScale()); |
| 788 | |
| 789 | Value = value; // Directly access the external value |
| 790 | } else { |
| 791 | // Values are not of the (good) column type |
| 792 | if (check) { |
| 793 | snprintf(g->Message, sizeof(g->Message), MSG(TYPE_VALUE_ERR), Name, |
| 794 | GetTypeName(Buf_Type), GetTypeName(value->GetType())); |
| 795 | return true; |
| 796 | } // endif check |
| 797 | |
| 798 | newval: |
| 799 | if (InitValue(g)) // Allocate the matching value block |
| 800 | return true; |
| 801 | |
| 802 | } // endif's Value, Buf_Type |
| 803 | |
| 804 | // Because Colblk's have been made from a copy of the original TDB in |
| 805 | // case of Update, we must reset them to point to the original one. |
| 806 | if (To_Tdb->GetOrig()) |
| 807 | To_Tdb = (PTDB)To_Tdb->GetOrig(); |
| 808 | |
| 809 | // Set the Column |
| 810 | Status = (ok) ? BUF_EMPTY : BUF_NO; |
| 811 | return false; |
| 812 | } // end of SetBuffer |
| 813 |
nothing calls this directly
no test coverage detected