I am trying to insert data from StringGrid into an Oracle DB table, for which I tried, as shown below.
function TfrmMapping.LoadtoTable: Boolean;
var
I, J: Integer;
lQuery, s: string;
lData: TArray<string>;
begin
for I := 0 to vTableColumns.count - 1 do
begin
if I <> vTableColumns.count - 1 then
begin
s := s + vTableColumns[I] + ',';
end
else
begin
s := s + vTableColumns[I];
end;
end;
for I := 1 to StrGrdLoadCSVData.RowCount - 1 do
begin
vSortedGrid.Add(StrGrdLoadCSVData.Rows[I].CommaText);
end;
for I := 0 to vSortedGrid.count - 1 do
begin
lQuery := 'Insert into ' + cmbBXDBTables.Text + '(' + s + ') values(' +
vSortedGrid[I] + ')';
DataModSample.FDQuery1.SQL.Clear;
DataModSample.FDQuery1.SQL.Add(lQuery);
DataModSample.FDQuery1.ExecSQL;
end;
Result := True;
end;
In the code, I add all the data of StringGrid (StrGrdLoadCSVData) to StringList (vSortedGrid), and now I try to skip StringList to add each row to the database, but I couldnβt insert because mine is taking values ββlike this
Insert into abc(sno,Name)values(1,welcome);
This is because there are no quotes in it welcome, it gives an error.
this is mistake: [FireDAC][Phys][Ora]ORA-00984:column not allowed here
How can I change my code to successfully insert data into Db.
EDIT
My table structure:
Name Type
--------- ------------
SNO NUMBER(38)
NAME VARCHAR2(15)
my desired result in the table should look like this:
SNO NAME
---------- ----------
1 Hello
2 Welcome
Values ββin the table starting with List
source
share