Can you modify the stored procedure, so that it always returns three columns, where the first column holds the category name, the second one holds the name of the importer and the third column holds the value for that category/importer combination?
If for example your current version of the stored procedure returns four columns and 2 lines like this:
Code:
catagory | imp1 | imp2 | imp3
---------+--------------+--------------+--------------
cat1 | val4imp1cat1 | val4imp2cat1 | val4imp3cat1
cat2 | val4imp1cat2 | val2imp2cat2 | val4imp3cat2
The new version would now return three columns and six lines:
Code:
category | impname | value
---------+---------+--------------
cat1 | imp1 | val4imp1cat1
cat1 | imp2 | val4imp2cat1
cat1 | imp3 | val4imp3cat1
cat2 | imp1 | val4imp1cat2
cat2 | imp2 | val4imp2cat2
cat2 | imp3 | val4imp3cat2
That way, your stored procedure no longer returns a variable number of columns.