Could LiteDAC support multi sqls?

Discussion of open issues, suggestions and bugs regarding LiteDAC (SQLite Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Eden0928
Posts: 47
Joined: Sun 22 Apr 2012 14:08

Could LiteDAC support multi sqls?

Post by Eden0928 » Thu 31 Oct 2013 03:17

I want used mulit SQLs, below:

Code: Select all

Create Table tmpTable(AA int);
Insert Into tmpTable(1);
Insert Into tmpTable(2);
Insert Into tmpTable(3);
...
Now, my delphi code is:

Code: Select all

LiteQuery1.SQL.Text := 'Create...';
LiteQuery1.ExecSQL();
LiteQuery1.SQL.Text := 'Insert Into...';
LiteQuery1.ExecSQL();
...

Could I to use TLiteQuery.SQL.TEXT := SQLs; and ExecSQL(); run once it? :oops:

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Could LiteDAC support multi sqls?

Post by AlexP » Thu 31 Oct 2013 09:46

Hello,

You can run several SQL commands in the TLiteSQL and TLiteScript components, for example:

Code: Select all

  LiteSQL1.SQL.Text := 'Create Table tmpTable(AA int);'#13#10 +
                       'Insert Into tmpTable(1), (2), (3)';
  LiteSQL1.Execute;

Eden0928
Posts: 47
Joined: Sun 22 Apr 2012 14:08

Re: Could LiteDAC support multi sqls?

Post by Eden0928 » Fri 01 Nov 2013 03:23

Hi,
I try the code, below:

Code: Select all

    _Command := TLiteSQL.Create(Self);
    _Command.Connection := LiteConnection1;
    _Command.SQL.Text := ''
      +'CREATE TABLE DEPT '
      +'( '
      +'   DEPTNO INTEGER NOT NULL, '
      +'   DNAME  VARCHAR(14), '
      +'   LOC    VARCHAR(13), '
      +'   PRIMARY KEY (DEPTNO) '
      +'); '
      + #13#10
      +'INSERT INTO DEPT '
      +'VALUES      (10, '
      +'             ''ACCOUNTING'', '
      +'             ''NEW YORK''); '
      + #13#10
      +'INSERT INTO DEPT '
      +'VALUES      (20, '
      +'             ''RESEARCH'', '
      +'             ''DALLAS''); '
      + #13#10
      +'INSERT INTO DEPT '
      +'VALUES      (30, '
      +'             ''SALES'', '
      +'             ''CHICAGO''); '
      + #13#10
      +'INSERT INTO DEPT '
      +'VALUES      (40, '
      +'             ''OPERATIONS'', '
      +'             ''BOSTON''); ';
    _Command.Execute();

  LiteQuery1.Open();
  ShowMessage(IntToStr(LiteQuery1.RecordCount));
It report "0"!!!

Why?

ZEuS
Devart Team
Posts: 236
Joined: Thu 05 Apr 2012 07:32

Re: Could LiteDAC support multi sqls?

Post by ZEuS » Fri 01 Nov 2013 11:13

Thank you for the information.
We have reproduced the problem with executing multiple SQL statements using TLiteSQL and will include the fix in the next LiteDAC build.
For now you can use the TLiteScript component instead of TLiteSQL to execute a sequence of SQL statements. More information about the TLiteScript component you can find in the LiteDAC documentation at our web-site: http://www.devart.com/litedac/docs/deva ... script.htm .

Post Reply