Forum Discussion

Petewilson's avatar
Petewilson
Contributor
6 years ago

Iterate through a DB query

 Morning all,

 

A bit of background first.

I have a group of projects, that was essetially the same project cloned, but ran with different SQL queries and counts via Jenkins. With nearly 14 almost identical projects, updating the code with improvements is a big overhead so i have altered my Jenkins input to pass in a parameter to one script and that then runs the specified DB Query, therefore meaning i only need to update one script base code rather than 14. Only issue i have is that since the row count changes dependant on the querry the count in the project Test Items is hard coded and from investigation appears that setting it via a variable isn't a current feature of TC.

 

Therefore i have needed to go back and stack the scripts and place them in a loop.

 

The Jenkins process calls a temp variable dependant on what was requested and then writes that to another temp variable for the rest of the scripts to reference.

 

In a  simple example;

In Jenkins, Test System A is selected to run and Jenkins passes the parameter to TC which tkaes the relevant DB Table Query, 'DriverA' and copies that to 'Driver'.

 

I am trying to write a loop to run through all the data held within the query, but i cannot figure out how to either read the temp variable 'Driver' or do i need to call it and build the ADO.Driver at the start of the loop and using the temp variables won't work?

 

Any help or advice where to look would be appreciated.

 

Also all my code is written in Delphi (legacy decision out of my hands)

  • I have solved it. A simple misuse of EOF and i needed to use IsEOF

     

    function ADODriverExampleNew(Driver);
    begin
    While Not Driver.IsEOF() do
    begin
    {Scripts}
    Driver.Next;
    end;
    end;

  • I have solved it. A simple misuse of EOF and i needed to use IsEOF

     

    function ADODriverExampleNew(Driver);
    begin
    While Not Driver.IsEOF() do
    begin
    {Scripts}
    Driver.Next;
    end;
    end;