[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

SQL INSERT

Posted on 1998-08-14
3
Medium Priority
?
170 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 300 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

650 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