#1 2015-09-18 13:14:51

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Any method to get all field names in CSV format for a TSQLRecord?

Hi Ab,

Is there a way to get all field names in CSV format for a TSQLRecord?

I need such a function because I want to avoid updating some of the fields via the '' parameter when calling Update().

It'll be idea to be able to:

const
  cFieldNotToUpdate = 'field1';
var
  fieldsToUpdate: string;
  myRec: TSQLPerson;
begin
  fieldsToUpdate := myRec.GetAllFieldNamesInCSVFormat; 
  //so that I can:
  fieldsToUpdate := ReplaceStr(fieldsToUpdate, cFieldNotToUpdate , '');
  aDb.Update(myRec, fieldsToUpdate);
  ...

I hope'll you get my point.

Or even better, in future versions to provide a new parameter for the Update() method called 'fieldsNotToUpdate'  which does the opposite of the 'customFields' param smile

Last edited by edwinsn (2015-09-18 14:20:15)


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2015-09-18 14:25:15

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,264
Website

Re: Any method to get all field names in CSV format for a TSQLRecord?

Use TSQLRecord.RecordProps.
The TSQLRecordProperties class gives access to the high-level ORM information from RTTI.

Then use e.g. the CSVFromFieldBits() method, and the other methods/properties.

Offline

#3 2015-09-19 04:10:53

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Any method to get all field names in CSV format for a TSQLRecord?

Great! Thanks AB!


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB