Topic: Create multiple records at once

Hi

I have a user form where I can choose what part of a car will be dismantled (checkboxes).
Lets say that I choose 3 parts. The starter, the alternator and the fuel pump.

I want to create 3 records at once, one for each product. I wll later edit each record to input more metadata.

What script should I use to accomplish this?

Finally what language is used in MVD and what book can I use to learn this language?

Thank you
George

Re: Create multiple records at once

Hello.


Check out this example
http://myvisualdatabase.com/forum/viewt … 802#p33802

Dmitry.

Re: Create multiple records at once

Thank you.

I managed to accomplish what I wanted following this : http://myvisualdatabase.com/forum/viewtopic.php?id=2722

Now I want to find a way to loop through all the records of a table and create another table with additional data.
For example:

I have a table with two fields Name, Surname.
I want to loop through all the records and create another table with fields Name2,Surname2

Name2,Surname2 will contain data from initial Name and Surname fileds but they will be modified by a script to contain additional information.

Can you please help me on how to do the following tasks with scripts:
1. loop through all records
2. save Name2 and Surname2 data to a different table

Thank you
George

Re: Create multiple records at once

Example

procedure Form1_Button5_OnClick (Sender: TObject; var Cancel: boolean);
var
    Results: TDataSet;
    s1, s2: string;
begin
    SQLExecute('PRAGMA synchronous = OFF'); // to increase speed of INSERTs

    try
        SQLQuery('SELECT firstname, lastname FROM person', Results);
        while not Results.Eof do
        begin
            s1 := Results.FieldByName('firstname').asString;
            s2 := Results.FieldByName('lastname').asString;
            if s1 <> '' then s1 := '''' + escape_special_characters(s1) + '''' else s1 := 'NULL';
            if s2 <> '' then s2 := '''' + escape_special_characters(s2) + '''' else s2 := 'NULL';

            SQLExecute('INSERT INTO person_ (firstname, lastname) VALUES ('+s1+','+s2+')'); // here you can add additional information to "person_"

            Results.Next;
        end;
    finally
        SQLExecute('PRAGMA synchronous = FULL');
    end;
end;
Dmitry.