Exemple #1
0
FBL_Begin_Namespace

/**********************************************************************************************/
void Clone_Current_Value( 
	VALUE_TYPE	inFldType, 
	I_Field_Ptr inSourceFld, 
	I_Field_Ptr inTargetFld )
{		
	switch( inFldType )
	{		
		case 	kTypeSound:
		case 	kTypeMovie:
		case 	kTypeBLOB:
// Commented because this way we must read/write TEXT as STRING to avoid
// double read/write (we use FirstRecord()/NextRecord() for source table and therefore 
// src TEXT field already has its value).		
//		case 	kTypeText:
		case	kTypePicture:
		{	
			try
			{
				if( inSourceFld->get_IsNull() == false )
				{
					I_FldBlob_Ptr sourceBlobFld = QI( inSourceFld, I_FldBlob );
					FBL_CHECK( sourceBlobFld );
					vuint32 datasize = sourceBlobFld->get_DataSize();

					if( datasize )
					{
						MemPtr<char> theData( datasize );
						sourceBlobFld->ReadData( theData, datasize );						
						I_FldBlob_Ptr targetBlobFld = QI( inTargetFld, I_FldBlob );
						targetBlobFld->WriteData( theData, datasize );				
					}
					else
					{
						// Zero data but not sql-NULL.
						I_FldBlob_Ptr targetBlobFld = QI( inTargetFld, I_FldBlob );
						targetBlobFld->WriteData( nullptr, 0 );
					}
				}
			}
			catch(...)
			{
			}			
		} break;

		default: 
		{
			// Common case:
			inTargetFld->put_Value( inSourceFld->get_Value() );

		} break;
	}
}
ArrayOfValues_Ptr GetNotBLOBValues( I_Table_Ptr inTable )
{
	FBL_CHECK( inTable );
	ArrayOfValues_Ptr result;

	vuint16 fldCount = inTable->get_FieldCount();
	if( fldCount )
		result = new ArrayOfValues();

	for( vuint16 i = 1; i <= fldCount; ++i )
	{
		I_Field_Ptr	pField = inTable->get_Field( i );
		I_Value_Ptr pValue;

		switch( pField->get_Type() )
		{
			case kTypeBLOB:
			case kTypePicture: 
			{
				;
			} break;

			default: 
			{
				// IS: 25.02.2008
				// http://valentina-db.com/bt/view.php?id=3048
				//pValue = pField->get_Value(forAdd);
				pValue = fbl_const_cast( pField->get_Value() );
				FBL_CHECK(pValue);							

			} break;
		}
		
		result->AddItem( pValue );
	}

	return result;
}