Page 1 of 1

How to specify the table name by using variables to output CSV

Posted: 11 Jan 2017, 10:13
by MegumiSawada
Hi,

The customer would like to output CSV data from the table using selectSQLcommand like Tutorial 6 - Tables and XML Documents.

They would like to specified the table name by using variables ('B'+JOB number).

Is it possible to specify the name of table (which output CSV data from) by using variables?
If Yes, could you please let me kno how?

e.g.
DefineObjectInstance {
className = "DynamicTable",
name = "Example2",
source = "sql",
selectSQLcommand = "EMPNO, SURNAME FROM DCXPGMLIB.<<File name variables>>",
resultColumnNames = { "TEXT1", "TEXT2" },
};

I appreciate your kind advice.

Best Regards,
Megumi Sawada

Re: How to specify the table name by using variables to output CSV

Posted: 13 Jan 2017, 09:45
by jeanmichel
The format is the same as how sql variables are defined in WHERE statement.
Example, in tables_dynamic.txt file define the following:
DefineObjectInstance {
className = "DynamicTable",
name = "Example2",
source = "sql",
selectSQLcommand = "EMPNO, SURNAME FROM DCXPGMLIB.:SQLVariableTableName",
resultColumnNames = { "TEXT1", "TEXT2" },
};

In AXES, example, in a button to output CSV, add the following script on its onClick property.
-------------------------------------------------------------------------------------------------------------------------------

var requestdetails = { SQLVariableTableName:"<<table name>>" };
var result = TABLEMANAGER.convertDynamicTable( "Example2", USERENV.dynamicTablesFile, requestdetails );
if (result.error == false)
{
var URL = document.location.protocol + "//" + document.location.host + "/ts/" + result.outputFileName;
window.open(URL,"_blank");
}

-------------------------------------------------------------------------------------------------------------------------------

For dropdown eXtension set the following property:
sqlVariables: ENV.SQL.SQLVariableTableName = "<<table name>>";

Re: How to specify the table name by using variables to output CSV

Posted: 19 Jan 2017, 17:37
by MegumiSawada
Hi Jean-Michel,

Thank you for your reply.
The customer has successfully implemented it with your instruction!

Best Regards,
Megumi Sawada