How To Get A List Of All Tables Referenced In Your Solution

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

How To Get A List Of All Tables Referenced In Your Solution

Postby bobcusick1332964082 » Thu Sep 19, 2013 4:56 pm

It may seem pretty simple - but I've had a couple of people ask me how to get a list of the referenced tables in a large solution because the customer has added a whole bunch of tables that have nothing to do with a particular solution.

This code is compatible with 5.x to 7.x (not optimized for new methodologies in 7.x - but will still run).

INSTRUCTIONS:

1) Make a new form in your solution with no datasource;
2) Make a TEXT form variable called "fv_tables";
3) Put the form variable on your form and make the displayType a TEXT_AREA;
4) Make a button on the form and create a new script called "getTables";
5) Put the code below into the "getTables" function;
6) Launch a client (Smart or Web), navigate to your form and press the button.

Here's the button code:

Code: Select all
function getTables(event) {
   var curFormName = controller.getName();
   var formNames = forms.allnames.sort();
   var tableNames = [];
   var curForm, i, frm;
   
   for(i=0; i< formNames.length; i++) {
      curForm = formNames[i];
      frm = solutionModel.getForm(curForm);
      if(tableNames.indexOf(frm.dataSource) == -1) {
         tableNames.push(frm.dataSource)
      }
   }
   
   fv_tables = tableNames.sort().join("\n");
}


Hope this helps someone out!

Cheers,

Bob
bobcusick1332964082
 
Posts: 85
Joined: Wed Mar 28, 2012 9:48 pm

Re: How To Get A List Of All Tables Referenced In Your Solut

Postby mboegem » Tue Sep 24, 2013 8:55 pm

Hi Bob,

thnkx for your tip!

Just want to add, that this might not give you all referenced tables.
Besides the datasources used in forms you can also have datasources referenced by methods as in:
Code: Select all
databaseManager.getFoundset('db:/myServer/myTable')

(there's different variations of using the 'get Foundset' function)

Also tables used in relations, valuelists, custom queries will not be returned.
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1382
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands


Return to How To

Who is online

Users browsing this forum: No registered users and 1 guest