alter column where fetchall = false

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
lao
Posts: 71
Joined: Wed 10 Dec 2008 10:56

alter column where fetchall = false

Post by lao » Mon 23 Jul 2012 13:36

Hello,
unidac 4.2.7 but it's same with unidac 4.1.6
provider postgresql

i have 1 unitable connected to table foo with options fetchall := false;
and active := true;
if i run a query like this:
alter table foo alter column mycolumn type varchar(25);//increase field size
query.execsql run indefinitely.
the query run perfectly when the unitable option fetchall = true.
sorry for my bad english
Regards

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

Re: alter column where fetchall = false

Post by AlexP » Mon 23 Jul 2012 14:29

hello,

This problem is due to the fact that untill all the data is read out from the table, the cursor for this table remains open, and you cannot change its structure. You should either execute DDL operations with the closed table, or after all the data is read out.

lao
Posts: 71
Joined: Wed 10 Dec 2008 10:56

Re: alter column where fetchall = false

Post by lao » Mon 23 Jul 2012 15:18

hello,
I open the table in form show, i wait and i execute table.last
before execute the query.
The queryreccount of table is true.
there are only 1000 records in the table.
regards

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

Re: alter column where fetchall = false

Post by AlexP » Tue 24 Jul 2012 12:49

hello,

If you execute the Last method before editing the field in the table, everything will work correctly, since all the data will be read out, and the cursor will be closed.

lao
Posts: 71
Joined: Wed 10 Dec 2008 10:56

Re: alter column where fetchall = false

Post by lao » Tue 24 Jul 2012 13:18

Hi AlexP,
i do it(table.last) and don't work.
I changed fetchall in my src like this thread:
"fetchall to false and queryrecount to true for postgresql"
maybe the changes are not complete and i need to change something more.
thanks for your help
Regards

lao
Posts: 71
Joined: Wed 10 Dec 2008 10:56

Re: alter column where fetchall = false

Post by lao » Wed 25 Jul 2012 09:47

Hi,
i have installed unidac without change in src.
if i set table to fetchall= false (in design time by double click on the table en select options tab -> fetchall=false).
i do table.last.
i try to modify structure in pgadmin3 sql and the query run indefinitely.
Please can you try to reproduce the error?
thanks

lao
Posts: 71
Joined: Wed 10 Dec 2008 10:56

Re: alter column where fetchall = false

Post by lao » Wed 25 Jul 2012 10:03

Hello,
the problem occur only if i set table active in design time(in object inspector active = true).
on form activate i set table.last.

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

Re: alter column where fetchall = false

Post by AlexP » Wed 25 Jul 2012 10:26

hello,

We cannot reproduce the problem. After calling the Last method, we managed to edit DDL with no errors.
Please send a small sample demonstrating the error to Alexp*devart*com

lao
Posts: 71
Joined: Wed 10 Dec 2008 10:56

Re: alter column where fetchall = false

Post by lao » Wed 25 Jul 2012 13:05

Hi,
it's very easy to reproduce the error:
put 1 tuniconnection and tpostgresqluniprovider on the form.
put one tunitable (named unitable1) with tablename = foo on the form and doubleclik on it and set fetchall to false on options tab;
in the inspector object set active to true; //very important
put one tuniquery (named uniquery1) on the form doubleclick on it and set fetchall=false on options tab and on sql tab:
alter table foo alter column oneVarcharColumn type varchar(25)
put one button on the form with this code:

unitable1.Last;
Uniquery1.execsql;
Showmessage('finish');

the message will not show, the execsql run indefinitely

Regards

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

Re: alter column where fetchall = false

Post by AlexP » Fri 27 Jul 2012 12:11

hello,

If the DataSet is opened at design-time with FetchAll=False - the cursor is already opened for this table; and when running the application, one more connection is created, and one more cursor is opened, where you really read out all the data (unitable1.Last). However, since there is one more open cursor for this table (at design-time), you cannot edit the DDL of the table. To solve the problem, you should open the DataSet at run-time.

lao
Posts: 71
Joined: Wed 10 Dec 2008 10:56

Re: alter column where fetchall = false

Post by lao » Fri 27 Jul 2012 12:28

Hello, thanks for your reply.
I will do like this.

I tried with interbase, and alter column work without to do table.last. Why not with postgresql?when we do table.last we lose the benefit of fetchall: = false. I have two applications that have access to the same table, the application 1 can not alter a column as the table opened by application 2.
Thanks

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

Re: alter column where fetchall = false

Post by AlexP » Mon 30 Jul 2012 10:48

hello,

This behaviour (ability to change the DDL of an open table) depends on a DB. InterBase allows to execute Alter commands for open tables, PostgreSQL doesn't. You can learn more details about this behaviour from the DB developers.

Post Reply