Board index » delphi » "Error Creating Cursor Handle"

"Error Creating Cursor Handle"

The following code generates that error message.  I have no idea
why... does anyone here have any ideas?

--------------------------------------------------------
   with SourceQuery do
      begin
         SQL.Clear;
         SQL.Add('INSERT AUTOARCHIVE');
         SQL.Add('SELECT * FROM TBL_AUTO');
         SQL.Add('WHERE DO_SaleCmplt <= "'+DateToStr(CutOffDate)+'"');
      end;

   try
      SourceQuery.Open;
   except
      StatusBar.SimpleText := 'Error Durring Archive. Archiver must be
stoped and restarted to continue Archiving.';
      ExitButton.Enabled := True;
      Exit;
   end;
--------------------------------------------------------

Brien King
bk...@primenet.com

 

Re:"Error Creating Cursor Handle"


Quote
bk...@primenet.com (Brien King) wrote:
>The following code generates that error message.  I have no idea
>why... does anyone here have any ideas?
>--------------------------------------------------------
>   with SourceQuery do
>      begin
>         SQL.Clear;
>         SQL.Add('INSERT AUTOARCHIVE');
>         SQL.Add('SELECT * FROM TBL_AUTO');
>         SQL.Add('WHERE DO_SaleCmplt <= "'+DateToStr(CutOffDate)+'"');
>      end;
>   try
>      SourceQuery.Open;
>   except
>      StatusBar.SimpleText := 'Error Durring Archive. Archiver must be
>stoped and restarted to continue Archiving.';
>      ExitButton.Enabled := True;
>      Exit;
>   end;
>--------------------------------------------------------
>Brien King
>bk...@primenet.com

Change your code to say :

SqlQuery.ExecSQL

The Open command expects a cursor to be returned.

Inserts/Deletes/Updates do not return cursors.  Only Select
transactions return cursors.

Had the same question a couple of days ago and recieved about 4-5 near
identical responses.

Thanks guys!

Re:"Error Creating Cursor Handle"


Quote
Brien King wrote:

> The following code generates that error message.  I have no idea
> why... does anyone here have any ideas?
>    with SourceQuery do
>       begin
>          SQL.Clear;
>          SQL.Add('INSERT AUTOARCHIVE');
>          SQL.Add('SELECT * FROM TBL_AUTO');
>          SQL.Add('WHERE DO_SaleCmplt <= "'+DateToStr(CutOffDate)+'"');
>       end;[SNIP]

I can only speak for Informix implementation of SQL, but I must say I
don't recognise "INSERT tablename SELECT stuff" as being valid syntax.
I would use "INSERT INTO tablename (SELECT stuff)".
Is this any help? :-)

Tim Kelly

Re:"Error Creating Cursor Handle"


Use TQuery.ExecSQL rather than TQuery.Open for SQL commands than don't
generate a result set.

-Bryan

Quote
Brien King wrote:

> The following code generates that error message.  I have no idea
> why... does anyone here have any ideas?

> --------------------------------------------------------
>    with SourceQuery do
>       begin
>          SQL.Clear;
>          SQL.Add('INSERT AUTOARCHIVE');
>          SQL.Add('SELECT * FROM TBL_AUTO');
>          SQL.Add('WHERE DO_SaleCmplt <= "'+DateToStr(CutOffDate)+'"');
>       end;

>    try
>       SourceQuery.Open;
>    except
>       StatusBar.SimpleText := 'Error Durring Archive. Archiver must be
> stoped and restarted to continue Archiving.';
>       ExitButton.Enabled := True;
>       Exit;
>    end;
> --------------------------------------------------------

> Brien King
> bk...@primenet.com

Other Threads