Board index » delphi » SQL Problem: ALTER statement causes error under TQuery

SQL Problem: ALTER statement causes error under TQuery

Has anyone got any further knowledge about this: When you want to use a
ALTER statement (eg. ALTER TABLE blabla
                      ADD field1 VARCHAR(20) )
in a TQuery's SQL editor, an exception is raised (Error while creating
cursor). The strange thing is that it does the alteration however! When
using Windows ISQL, the same statement raises no errors (naturally!).

Any comments will be much appreciated.

Hossein

 

Re:SQL Problem: ALTER statement causes error under TQuery


In article <01bbcc82$ded77ea0$0822a...@h.jelveh>, s...@vworlds.it says...

Quote

>Has anyone got any further knowledge about this: When you want to use a
>ALTER statement (eg. ALTER TABLE blabla
>                      ADD field1 VARCHAR(20) )
>in a TQuery's SQL editor, an exception is raised (Error while creating
>cursor). The strange thing is that it does the alteration however! When
>using Windows ISQL, the same statement raises no errors (naturally!).

>Any comments will be much appreciated.

>Hossein

How do you execute your TQuery. If you use open the describes error occurs -
try ExecSQL for SQL-Statements which don't give back a cursor.

Stefan

Re:SQL Problem: ALTER statement causes error under TQuery


Quote
"Hossein Jelveh" <s...@vworlds.it> wrote:
>Has anyone got any further knowledge about this: When you want to use a
>ALTER statement (eg. ALTER TABLE blabla
>                      ADD field1 VARCHAR(20) )
>in a TQuery's SQL editor, an exception is raised (Error while creating
>cursor). The strange thing is that it does the alteration however! When
>using Windows ISQL, the same statement raises no errors (naturally!).
>Any comments will be much appreciated.
>Hossein

you should use TQuery.ExecSQL.

if you use TQuery.Open (as you almost certainly are) the TQuery
component tries to open a cursor to point into a return set, which it
expects from a Select statement.   Since this is an ALTER statement,
it gets no return set, therefore is unable to open a cursor, hence the
exception.

Other Threads