Page 1 of 1

[solved] I can't use "DROP TABLE" - Lazaruz - ZEOS

Posted: 13.11.2012, 17:57
by Mando
Hello:

That's my problem:

I'm developing an aplication than generates a table according some values wich determine how much columns table should have.

The first time I lanuch the process it works properly, but second time, I must drop that table. I close de component (TZQuery) first, but I get this error :
(see attachment)


I'm currently using Lazarus 1.1, FPC 2.6.6.
Before installing 7.1-beta , I was installed 6.6.6 with a patch and my application worked fine.

Thera are any solution?

regards

Posted: 13.11.2012, 20:45
by EgonHugeist
Mando,

??? currently i can't say anything about your issue. But i know this issue if i've opened the table with another external application like FlameRobin.

Can you check this stupid advice before?

On the other hand do i need a simple app to reproduce this issue. I can't fix something i couldn't see..

Posted: 15.11.2012, 13:16
by Mando
Hi. Thanks for your response.
I solved desinstalling version 7.0.1-beta an reinstalling 6.6.7 stable. But I still have this problem:

I've a table with a numeric (decial, float, double ...) field. I post into it a value less than 10 with a 2 (or more) decimals (p.e. 5.92) and the value is posted right in the table, but the control (aka TDBEdit, TDBGrid) doesn't reflect the correct value, it shows the value without last decimal. (p.e 5.92 -> 5.9). That doesn't occurr with values greater than or equal to 10.
I know I can play with precission in the field definition, but I'm developing a Database administration utility, and I open the tables dinamically.

Is that a bug? zeos 7 alpha has the same behavior than 6.6.7 stable.
What can i do to solve it ?

SQLdb works properly.

Posted: 15.11.2012, 16:46
by EgonHugeist
Mando,

that's not a solution for me by switching back to a deprecated and no more maintained branch. Please give me a little testcase to reproduce this issue. And can you test it with svn too?:
http://svn.code.sf.net/p/zeoslib/code-0 ... es/testing

Posted: 15.11.2012, 18:50
by EgonHugeist
Btw. i remember the floting point decimal issue.

it's a bug of lauarus afaik. Thought i've seen this somewhere in the bugtracker... But i don't know where eyactly right now. )):

Posted: 15.11.2012, 19:21
by Mando
Hello:

I tryed to install svn and I got this errors:


Z:\Lazarus\ControlesLazarus\ZEOSDBO-7.0.1-beta - svn\src\dbc\ZDbcIntfs.pas(205,39) Error: Identifier not found "TZControlsCodePage"
Z:\Lazarus\ControlesLazarus\ZEOSDBO-7.0.1-beta - svn\src\dbc\ZDbcIntfs.pas(205,50) Error: Identifier not found "cCP_UTF16"
Z:\Lazarus\ControlesLazarus\ZEOSDBO-7.0.1-beta - svn\src\dbc\ZDbcIntfs.pas(205,50) Error: Illegal expression
Z:\Lazarus\ControlesLazarus\ZEOSDBO-7.0.1-beta - svn\src\dbc\ZDbcIntfs.pas(290,43) Error: Identifier not found "PZConSettings"
Z:\Lazarus\ControlesLazarus\ZEOSDBO-7.0.1-beta - svn\src\dbc\ZDbcIntfs.pas(824,43) Error: Identifier not found "PZConsettings"
Z:\Lazarus\ControlesLazarus\ZEOSDBO-7.0.1-beta - svn\src\dbc\ZDbcIntfs.pas(912,1) Fatal: There were 5 errors compiling module, stopping


My Lazarus version:
1.1
date 2012-11-15
FPC 2.6.0
SVN: 37904

Posted: 15.11.2012, 19:32
by EgonHugeist
Mando,

you're mixing old with new files. That's slightly an anoying issue for me because a lot of people running into the same issue. Drop all old files, deinstall the Zeos components. Compile ZComponent again and install the compoents..

Posted: 15.11.2012, 21:29
by EgonHugeist
Mando,

i made a testcase:

Code: Select all

    with ZQuery1 do
    begin
      Close;

      ZConection1.GetTableNames('BLABLA', tables);
      if tables.Count = 0 then
      begin
        SQL.Text := 'create table blabla(feld1 varchar(20))';
        ExecSQL;
      end;
      SQL.Text := 'select * from blabla';
      Open;
      Close;
      SQL.Text := 'drop table blabla';
      ExecSQL;
    end;
and it works very well with Zeos7. Now tell me what you're doing?

Posted: 16.11.2012, 14:13
by Mando
Hello, thaks for your interest:

Your testcase works properly, but try this:

Code: Select all

 with ZQuery2 do
  begin
    close;
    SQL.text:='CREATE TABLE PEPE (FAMILIA CHAR(20), N INTEGER, DB DOUBLE PRECISION, NU NUMERIC(10,4), FL FLOAT)';
    execSQL;
  end;

  with ZQuery1 do
  begin
    SQL.text:='SELECT * FROM PEPE';
    open;
    close;
  end;

  with ZQuery2 do
  begin
    SQL.text:='DROP TABLE PEPE';
    execSQL;

  end;

Posted: 16.11.2012, 18:42
by Mando
Hello again:

I discovered what is the problem.

You mut use the same component (TZQuery) to do all operations. Create, open and drop the table.

In my first project, I used Zconnection1.ExecuteDirect to create and to drop a table. This worked fine until the table is opened with a ZQuery component for working with data, in this case, drop table chrash.

Another flaw is that right after funcioa GetTableNames Creart or clear the table. I reconnect the database to get the list correctly. Instead, if I use a query to the table RDB $ RELATIONS I get the updated list.

All this works using SQLdb components.

Posted: 16.11.2012, 20:06
by EgonHugeist
Mando,

ahhhh! Uh how to explain. Since Zeos7 is nearly everywhere(i'm working on SQLite currently) able to use prepared statements (preprapere once execute multiple times) we close the resultsets. But the statement won't be closed as long the TZQuery.SQL.Text is the same or you do not call TZQuery.UnPrepare.

Both variants will close the statment and the table is unlocked.
All this works using SQLdb components.
sade that they have no prepared statments currently ))):
Another flaw is that right after funcioa GetTableNames Creart or clear the table. I reconnect the database to get the list correctly. Instead, if I use a query to the table RDB $ RELATIONS get the updated list.
That's also not a real issue. Zeos7 is mighty on dealing with metainformation. But fetching them eats time. So Zeos7 caches all the metainformations and do not recall the same request. So we are terribly fast. So if you drop a still cached table you've to reopen the connection which refreshes all still cached metainformations.

Well you're writing an Admin tool so i'm not surprissed that you're strunceling into these behavior issues.

Again in summary:

Code: Select all

 with ZQuery2 do
  begin
    close;
    SQL.text:='CREATE TABLE PEPE (FAMILIA CHAR(20), N INTEGER, DB DOUBLE PRECISION, NU NUMERIC(10,4), FL FLOAT)';
    execSQL;
  end;

  with ZQuery1 do
  begin
    SQL.text:='SELECT * FROM PEPE';
    open;
    close;
    Unprepare;
  end;

  with ZQuery2 do
  begin
    SQL.text:='DROP TABLE PEPE';
    execSQL;

  end; 
That code works properly.

Posted: 16.11.2012, 20:39
by Mando
OOOOOOHH!!!!!


Thankyou very much!!!.

The problem is solved.....


regards