Solved

SQL INSERT

Posted on 1998-08-14
3
168 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

695 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