Hi all,
Im rather new to programming in general so go easy on me,
what im trying to do is run an sql query that returns multiple records and save the various fields into an various arrays and then use an individual array as a variable to insert information into another table of the database.
procedures go a little like this:
var
array1:array[1..9999] of integer;
array2:array[1..9999] of string;
procedure example1;
begin
dbConnectMain;
fMain.IBMain1.Connected := False;
fMain.SQLquery.Close;
fMain.SQLquery.SQL.text := 'select fieldX,fieldY from table where table.fieldX = :variable ';
fMain.SQLquery.Params.ParamByName('variable').Asinteger := variable1;
fMain.IBMain1.Connected := True;
fMain.Transaction.Active := True;
fMain.SQLquery.Open;
array1[ x ]:= fMain.SQLquery.FieldByName('fieldY').AsVariant;
array2[ x ]:= fMain.SQLquery.FieldByName('fieldY').AsVariant;
end;
insert procedure:
procedure insert;
begin
example1;
dbConnectMain;
fMain.SQLquery.SQL.Text := ('insert into table2 (fieldt1,fieldt2) values (:array1,:array2)');
fMain.SQLquery.Params.ParamByName('array1').AsString := array1[ x ];
fMain.SQLquery.Params.ParamByName('array2').Asstring := array2[ x ];
fMain.SQLquery.ExecSQL;
fmain.Transaction.Commit;
end;
any help pointing out where I'm going wrong and suggetions will be much appreciated.
Thanks