Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Tables and Queries

Posted on 2002-05-31
6
Medium Priority
?
210 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
[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
  • 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
Technology Partners: 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

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…
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…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

722 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