Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
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?

Labels (1)
6 Replies
petter
Partner - Champion III
Partner - Champion III

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

alexandros17
Partner - Champion III
Partner - Champion III

Connect to ... DB1

Select... From .Table1

Connect to ... DB2

Select... From .Table2

Not applicable
Author

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.

Anonymous
Not applicable
Author

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.

petter
Partner - Champion III
Partner - Champion III

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
Specialist
Specialist

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.