Home > Back-end >  A SQL statement, or the Delphi method
A SQL statement, or the Delphi method

Time:10-15

I have a table, I'll add a field to the table;
I want to add up all values in the table each record, encryption, to generate an encrypted string,
So you ask how many records are generated, how many insert at the end of the string of new fields,
How to carry on the batch operation to cycle on the table? Because I can't see how to write, behind the where
So do not know how to start,

CodePudding user response:

You can every time a record to add up all the values, encryption, generate an encrypted string
Then iterate through all the records add up the string

Such as the original field a, b, c for the new d
STR:='select a, b, c, d (a + b + c) as the from XXX'
ADOQuery. SQL. The add (STR);
ADOQuery1. Oepn;
StrAdd: string; You finally get that all the records of new field
While not ADOQuery1. Eof do
The begin
StrAdd:=strAdd + FieldByName (' d '). Asstring;
next;
end;
I wrote it was a careless should be able to understand

CodePudding user response:

You may not know what I mean, I mean, each record to generate a string, inserted behind when the record of the new field, if there are 100 records, will generate 100 string, is much more behind each record a value (add up when the records generated string)

CodePudding user response:

Update the set d=(a + b + c) from the table

CodePudding user response:

reference 1st floor xsl510079027 response:
you can every time a record to add up all the values, encryption, to generate an encrypted string
Then iterate through all the records add up the string

Such as the original field a, b, c for the new d
STR:='select a, b, c, d (a + b + c) as the from XXX'
ADOQuery. SQL. The add (STR);
ADOQuery1. Oepn;
StrAdd: string; You finally get that all the records of new field
While not ADOQuery1. Eof do
The begin
StrAdd:=strAdd + FieldByName (' d '). Asstring;
next;
end;
I wrote it was a careless should be able to know
learning reference

CodePudding user response:

refer to the second floor KZZCK response:
you may not know what I mean, I mean, each record to generate a string, inserted behind when the record of the new field, if there are 100 records, will generate 100 string, is much more behind each record a value (add up when the records generated string)


I see you just to add up new fields for all other fields
Update the set d=(a + b + c) from table
That this will meet the will to traverse the list of each record
+ where XXX what you want to write on the filter conditions
  • Related