Solved

SQL INSERT

Posted on 1998-08-14
3
162 Views
Last Modified: 2010-04-04
The codes here runs fine until the RevertQuery.Open.
It display a message saying 'Error creating cursor handle'
after records are selected.

RevertQuery.Close;
RevertQuery.SQL.Clear;
RevertQuery.SQL.Add( ' INSERT INTO CALLS.DB ');
RevertQuery.SQL.Add( '( SERIALNO, DATECALL,  CALLTYPE,   ');
RevertQuery.SQL.Add( '  TIMECALL, EXTENSION, TRUNK,      ');
RevertQuery.SQL.Add( '  DURATION, DEST,      PH_NUMBER,  ');
RevertQuery.SQL.Add( '  COST,     TRAN_FROM, CALLSTATUS )');
RevertQuery.SQL.Add( ' SELECT ');
RevertQuery.SQL.Add( '  SERIALNO, DATECALL,  CALLTYPE,   ');
RevertQuery.SQL.Add( '  TIMECALL, EXTENSION, TRUNK,      ');
RevertQuery.SQL.Add( '  DURATION, DEST,      PH_NUMBER,  ');
RevertQuery.SQL.Add( '  COST,     TRAN_FROM, CALLSTATUS  ');
RevertQuery.SQL.Add( ' FROM xxxCALLS.DB ');
RevertQuery.Open;
0
Comment
Question by:rickytong
3 Comments
 

Accepted Solution

by:
DPedrelli earned 100 total points
Comment Utility
When you Open a TQuery it expects a result set tries to create a cursor to hold the results.  To avoid this problem when dealing with SQL statements that don't have result sets then issue TQuery.ExecSQL.  It will execute the SQL statement without expecting a result set to be returned.
0
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
Take a look at this question(http://www.experts-exchange.com/topics/comp/lang/delphi/Q.10072099). It answers exactly what you need :)

Regards,
Viktor Ivanov

0
 
LVL 2

Expert Comment

by:333
Comment Utility
Ye,
DPedrelli is right. But you must split your SQL statement in two parts. In your case it should be

RevertQuery.Close;
{-----------1st part------------}
RevertQuery.SQL.Clear;
RevertQuery.SQL.Add( ' INSERT INTO CALLS.DB ');
RevertQuery.SQL.Add( '( SERIALNO, DATECALL,  CALLTYPE,   ');
RevertQuery.SQL.Add( '  TIMECALL, EXTENSION, TRUNK,      ');
RevertQuery.SQL.Add( '  DURATION, DEST,      PH_NUMBER,  ');
RevertQuery.SQL.Add( '  COST,     TRAN_FROM, CALLSTATUS )');
RevertQuery.ExecSql;
{-----------2nd part------------}
RevertQuery.SQL.Clear;
RevertQuery.SQL.Add( ' SELECT ');
RevertQuery.SQL.Add( '  SERIALNO, DATECALL,  CALLTYPE,   ');
RevertQuery.SQL.Add( '  TIMECALL, EXTENSION, TRUNK,      ');
RevertQuery.SQL.Add( '  DURATION, DEST,      PH_NUMBER,  ');
RevertQuery.SQL.Add( '  COST,     TRAN_FROM, CALLSTATUS  ');
RevertQuery.SQL.Add( ' FROM xxxCALLS.DB ');
RevertQuery.Open;

AP
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now