Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Tables and Queries

Posted on 2002-05-31
6
Medium Priority
?
212 Views
Last Modified: 2010-04-04
Hi,

I need some help with regards to Paradox tables and SQL queries.

I am developing a database solution that scans a table of information for certain criteria.
The criteria is returned and populated in a dbGrid component. OK up to now.

With the information returned, I want to fill in a field with a value. But only fill in the field on the records that have been returned by my query.

How can I accomplish this?
Any help would be great.

Many Thanks
0
Comment
Question by:HotRod40
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:bes67
ID: 7046641
Hi,

as far as I understand you have 2 components: TTable and TQuery (with the select on the same table with some conditions (where clause)). And your Query's result set is not "Live".
It seems to me that you can intclude in select field (or fields) that compose the primary index of a table and then make something like this:

Query.First;
while not Query.Eof do
begin
  if Table.Locate('Field_1', Query.FieldByName('Field_1').Value,[]) then
    Table.FieldByName('Field_2').Value := aValue;
  Query.Next;
end;

bes67
0
 

Author Comment

by:HotRod40
ID: 7046706
I have a table which has a filter set on it.
When the table is opened the filter brings up all records where the FirstInvoice is set to True.
FirstInvoice is a field in my table.
The filter is: FirstInvoice = 'True'

The records where the FirstInvoice is set to True are shown in a dbGrid component.

I want to amend another field called Flag on each record and populate it with a value, but I only want to update the records that have been retrieved.

I have heard that you can use a ResultSet or something??

Hope this helps
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7046715
update tablename set fieldname = value where ...
(the whereclause u used for the query)
0
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!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 7046718
more specific to yours

update tablename set flag = avalue where firstinvoice = true
0
 
LVL 1

Expert Comment

by:bes67
ID: 7046773
Try something like this

Drop TQuery on your form with SQL property set to

UPDATE TABLE_NAME SET
FLAG = :Val
WHERE FIRSTINVOICE = 'True'

Database property of TQuery must be the same as the one in TTable

write somewhere in you code

Query.ParamByName('Val').Value := aValue;
Query.ExecSQL;
Table.DisableControls;
try
Table.Refresh;
finally
Table.EnableControls;
end;
0
 
LVL 1

Accepted Solution

by:
bes67 earned 225 total points
ID: 7046804
Try something like this

Drop TQuery on your form with SQL property set to

UPDATE TABLE_NAME SET
FLAG = :Val
WHERE FIRSTINVOICE = 'True'

Database property of TQuery must be the same as the one in TTable

write somewhere in you code

Query.ParamByName('Val').Value := aValue;
Query.ExecSQL;
Table.DisableControls;
try
Table.Refresh;
finally
Table.EnableControls;
end;
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

879 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