Solved

SQL INSERT

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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

20 Experts available now in Live!

Get 1:1 Help Now