Solved

SQL INSERT

Posted on 1998-08-14
3
167 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Accepted Solution

by:
DPedrelli earned 100 total points
ID: 1362157
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
ID: 1362158
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
ID: 1362159
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
code issue 8 185
SUM 2 INTEGER ARRAYS INTO 1 10 111
Microsoft Access 97 and Delphi XE2 9 73
shape, triangle, dbctrlgrid 3 33
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…

733 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