Link to home
Start Free TrialLog in
Avatar of ajtsoukalas
ajtsoukalasFlag for United States of America

asked on

Generic access to different queries to the same table

I have an mySQL database which can have up to 6 queries on a given table.

I would like to access them with a generic procedure without an if then else construct as the processing on the queries will be the same for all 6.  I need to be
able to reference the queries individually and display them simultaneously.  Right now I have

procedure ProcessQuery(CodeType)

if CodeType = "AAA" then
   begin
   queryAAA.
   queryAAA.
   queryAAA.
   end
else
if CodeType = "BBB" then
   begin
   queryBBB.
   queryBBB.
   queryBBB.
   end;

what I would like to do is something like

procedure ProcessQuery(CodeType)
begin
  queryCodeType.
  queryCodeType.
  queryCodeType.
end;

Can I do it and How Would I do it if I can?

AJ

Avatar of calinutz
calinutz
Flag of Romania image

Have you tryed:
TQuery(FindComponent('query'+CodeType));
?

Regards
ASKER CERTIFIED SOLUTION
Avatar of calinutz
calinutz
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ajtsoukalas

ASKER

I like both answers
I am going to split the points