Page 1 of 1

Could LiteDAC support multi sqls?

Posted: Thu 31 Oct 2013 03:17
by Eden0928
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:

Re: Could LiteDAC support multi sqls?

Posted: Thu 31 Oct 2013 09:46
by AlexP
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;

Re: Could LiteDAC support multi sqls?

Posted: Fri 01 Nov 2013 03:23
by Eden0928
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?

Re: Could LiteDAC support multi sqls?

Posted: Fri 01 Nov 2013 11:13
by ZEuS
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 .