Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SQL Select from several Database

Hi,

First sorry for my english..

I have 5 sql query, whose select many table. But now, i have an other database with the same name table.

I want to know if it's possible (with the qwd script or macro or other way), to give to the user the choice of the database ?

In the FROM of my query i have to put the name of the database before the table name, can i put a variable link to a listbox with "SQL SHOW DATABASE" ?

If you have any question i'm here, it's important.

cordially.

18 Replies
Not applicable
Author

Hi ShambhuB, thanks

With this solution i have to change the script and create a .txt for each of news databases. If it's was just for me ok, but it's for my colleagues, they are zero

Anonymous
Not applicable
Author

As you are "new" to qlikview, I'd suggest you start simple and just use 2 database sources and hard code it.

When you have got that working, tested and you are confident you understand it, then worry about the loop and the xls.

That is exactly how I started when I was building my solution.

Not applicable
Author

I don't think there is a simple user friendly way to do this.

I think you will need to generate some training materials for your users to assist them.

Not applicable
Author

I have my query with two databases concatenate

sql select * from base10_05.tableA concatenate select * from base14_05.tableA

(thanks for your help)

Not applicable
Author

be damned final user

Not applicable
Author

i've tried something like this :

  • A xls files connect to my server with the list of databases (sql show database) and a column choice where the user copy past the database that he want.

Capture.PNG

  • in my script :

//connexion a la base

ODBC CONNECT TO BasesPourQVW;

LOAD DataBases,

     Choix

FROM

(biff, embedded labels, table is [Bases MySQL$]);

Let vbaseSelected = Choix;

hourlyvalue_time :

SQL SELECT *

FROM $(vbaseSelected).mod_bi_servicemetrics

JOIN $(vbaseSelected).mod_bi_metrichourlyvalue on $(vbaseSelected).mod_bi_servicemetrics.id = $(vbaseSelected).mod_bi_metrichourlyvalue.servicemetric_id ;

But vbaseSelected return nothing.. so -> sql error : No database selected

jonathandienst
Partner - Champion III
Partner - Champion III

Use


Let vbaseSelected = 'Choix';

or

Set vbaseSelected = Choix;

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

it return "choix" not the content

Not applicable
Author

i've done this, it works but i keep the topic not resolve if you have an other solution.

  • A xls files connect to my server with the list of databases (sql show database) and a column choice where the user copy past the database that he want.

Capture.PNG

  • in my script :

//connexion a la base

ODBC CONNECT TO BasesPourQVW;

LOAD DataBases,

     Choix

FROM

(biff, embedded labels, table is [Bases MySQL$]);

Let vbaseSelected = peek('Choix',0);

hourlyvalue_time :

SQL SELECT *

FROM $(vbaseSelected).mod_bi_servicemetrics

JOIN $(vbaseSelected).mod_bi_metrichourlyvalue on $(vbaseSelected).mod_bi_servicemetrics.id = $(vbaseSelected).mod_bi_metrichourlyvalue.servicemetric_id ;

  • it makes a step for the user so it's not really optimal, but if there aren't other answer, it doesn't matter

Thanks everybody