Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Not applicable

Change Script ?

Hey guys,

I have 2 Databases from two companys, which i want to use in one application. The Databases are the same concerning to Tablenames etc..

So I would only have to change the FROM Statement in my loadparts like

LOAD

*

SQL SELECT

*

FROM companyA...

to

LOAD

*

SQL SELECT

*

FROM companyB...

So what i want to achieve is 2 scripts, one for company A and one for company B which can be easily changed in one application.

Any Ideas?

6 Replies
MVP
MVP

Re: Change Script ?

You should probably ADD a new CONNECT statement after the first LOAD and before the second LOAD.

Re: Change Script ?

Connect to ... DB1

Select... From .Table1

Connect to ... DB2

Select... From .Table2

Not applicable

Re: Change Script ?

But how can I switch between these two different scripts?

I dont want to have all the data from both companies in the application at once.

neetha_p
Honored Contributor

Re: Change Script ?

hi leon,

You can achieve your requirement in same Script .Make a connection to a first DB and then code or script under that connection and Store files from that database in your system than disconnect the database. Next, Make a connection to a second DB and then code or script under that connection and Store files from that database in your system than disconnect the database and so on.

1st Database:

Connection String #1

ODBC Connect to .........

TableA

Load

.....

....

From

Store TableA  into …/..../.qvd(qvd);

Disconnect;

2nd Database:

Connection String #2

ODBC Connect to .........

TableB

Load

.....

....

From

Store TableB into …/..../.qvd(qvd);

Disconnect;

 

  1. Etc...

At a time, there will be only one Connection Active.

You can use Number of Connect Commands to fetch Data.

MVP
MVP

Re: Change Script ?

LET CompanyAConn = 'CONNECT def.....';

LET CompanyAFrom = '......';

LET CompanyBConn = 'CONNECT xyz.....';

LET CompanyBFrom = '......';

LET Company = 'A';   // Change here to switch the company

LET CompanyConnectString = Company$(Company)Conn;

LET FromClause = Company$(Company)From;

$(CompanyConnectString);

LOAD

     *;

SQL

   SELECT

        .....

   FROM $(FromClause);

puttemans
Valued Contributor

Re: Change Script ?

You could make the 'from' statement using a variable (vCompany), which you define with an 'input box'  (vCompany=A or B) for instance. That way you can easily switch between both companies in the same application.