Solved

Editing dataset using SQL

Posted on 2004-03-29
7
133 Views
Last Modified: 2010-04-05
I have two fields Field1 and Field2 in my table. I want to update Field1 using Field2 using the following code:

Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Update debts Set Field1=:PPercentAZM * Field2 Where (Currency="$")and(Calcul=True)');

Query1.ParamByName('PPercentAZM').AsFloat := Table1.FieldByName('FieldName').AsFloat;
Query1.Open;
It gives me an error with message "Error creating cursor handle". I tried to do something via SQL Explorer using the following code:

Update debts Set Field1=Field2 * 4924 Where (Currency="$")and(Calcul=True)

It's not giving error, but doesn't calculate anything.
What i should do in order to change values of all fields in dataset using values of other fields? (Certainly with SQL)
0
Comment
Question by:ferhad
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10702859
instead of
>Query1.Open;

use
Query1.ExecSQL;

your statement seems to be ok

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10702862
btw. just don't forget to commit
0
 
LVL 11

Expert Comment

by:calinutz
ID: 10718292
Its not SQl .... it's just Delphi help files... you should read it. If you have an SQL (query) that does not return any cursor then of course you have to use the ExecSQL...
Just like kretzschmar already  wrote. And you solved the problem, I'm sure.(just type Query1.Active and press F1 on the Active property  and you should fine very easily the help that you need)
Cheers.
0
 
LVL 2

Author Comment

by:ferhad
ID: 10729877
Thank you  for your advance
I have found that Update function doesn't work with BCD fields. In SQLExplorer have tested
the following code:

Update test Set Field3=Field1*5

If the type of Field3 is BCD it doesn't work. If integer it works. The problem is so I can
change type of Field3 into Integer, but not the type of Field1. When type of Field1 is BCD
and the type of Field3 is Integer what should I do in order to calculate Field3 using Field1?
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 13275895
PAQed with points refunded (100)

modulo
Community Support Moderator
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

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