Page 1 of 1
alter column where fetchall = false
Posted: Mon 23 Jul 2012 13:36
by lao
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
Re: alter column where fetchall = false
Posted: Mon 23 Jul 2012 14:29
by AlexP
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.
Re: alter column where fetchall = false
Posted: Mon 23 Jul 2012 15:18
by lao
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
Re: alter column where fetchall = false
Posted: Tue 24 Jul 2012 12:49
by AlexP
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.
Re: alter column where fetchall = false
Posted: Tue 24 Jul 2012 13:18
by lao
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
Re: alter column where fetchall = false
Posted: Wed 25 Jul 2012 09:47
by lao
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
Re: alter column where fetchall = false
Posted: Wed 25 Jul 2012 10:03
by lao
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.
Re: alter column where fetchall = false
Posted: Wed 25 Jul 2012 10:26
by AlexP
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
Re: alter column where fetchall = false
Posted: Wed 25 Jul 2012 13:05
by lao
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
Re: alter column where fetchall = false
Posted: Fri 27 Jul 2012 12:11
by AlexP
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.
Re: alter column where fetchall = false
Posted: Fri 27 Jul 2012 12:28
by lao
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
Re: alter column where fetchall = false
Posted: Mon 30 Jul 2012 10:48
by AlexP
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.