Page 1 of 1

It does not work delete from

Posted: 21.11.2011, 13:26
by CHERTS
hello

I'm using the latest version from SVN zeoslib

I want to delete all data from a table uin_test

when the query: delete from uin_test where 1;
from the table uin_test nothing is removed

what could be wrong?

I create a table like this:

Code: Select all

CREATE TABLE uin_test (
  id integer primary key autoincrement not null unique,
  proto_name int(2) default 0 not null,
  my_nick varchar(128) default null,
  my_uin varchar(128) default null,
  nick varchar(128) default null,
  uin varchar(128) default null,
  msg_direction int(1) default 0 not null,
  msg_time timestamp(14) not null,
  msg_text text
);
insert data and execute procedures SQL_Zeos_Exec('delete from uin_test where 1;');

MainForm.pas:

Code: Select all

procedure TMainForm.DeleteAllHistoryClick(Sender: TObject);
begin
SQL_Zeos_Exec('delete from uin_test where 1;');
end;

procedure TMainForm.SQL_Zeos_Exec(Sql: WideString);
begin
    if ZConnection1.Connected then
    begin
         ViewerQuery.Close;
         ViewerQuery.SQL.Clear;
         ViewerQuery.SQL.Text := Sql;
         ViewerQuery.ExecSQL;
    end;
end;
MainForm.dfm:

Code: Select all

  object ZConnection1: TZConnection
    TransactIsolationLevel = tiReadCommitted
    Left = 216
    Top = 200
  end

  object ViewerQuery: TZQuery
    Connection = ZConnection1
    Params = <>
    Left = 288
    Top = 200
  end

Posted: 21.11.2011, 13:49
by jeremicm
You need to add condition...


delete from uin_test where uin_test.id = 1; (i guess you're deleting values by index field)

Posted: 22.11.2011, 04:03
by CHERTS
jeremicm wrote:You need to add condition...
delete from uin_test where uin_test.id = 1; (i guess you're deleting values by index field)
I want to delete all data from a table uin_test

I run a query

delete from uin_test;

but data is not deleted

Posted: 17.12.2011, 22:17
by mdaems
In that case I would do 'Delete from uin_test;'
Is 'where 1' equal to 'where true' in sqlite?

Mark