Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Close an ODBC connection?

Hi,

I would like to run two SELECTs one after the other from two different databases - but the structure and the table_name are the same, so the two LOAD statements are in fact identical. Can I somehow close the first connection before establishing the second one so QlikView only has one database connection at a time and there can be no confusion between the databases?

Thanks a lot!

Best regards,

DataNibbler

1 Solution

Accepted Solutions
marcus_sommer

Hi DataNibbler,

that's like qlik worked - each new connection closed a possible previous one because it could be always only one connection exists. But to make sure you could also ad a Disconnect;

- Marcus

View solution in original post

5 Replies
marcus_sommer

Hi DataNibbler,

that's like qlik worked - each new connection closed a possible previous one because it could be always only one connection exists. But to make sure you could also ad a Disconnect;

- Marcus

datanibbler
Champion
Champion
Author

Hi Marcus,

well, I will definitely do that - it looks like there was a "misunderstanding" between the databases even if it should not be possible from what you say - I see that when I look at the "plant_key" - each of the two databases belongs to a different plant and when I load from the other database, it should say "A163" for all but maybe about 10 records where there would  be "A164" - but until now when I had first one "ODBC connect" and a LOAD and a STORE, then another "ODBC connect" and a LOAD and a STORE, the plant_key for the second one (which should be "A163") said "A164" in ALL records 😉

Then I just disactivated/ commented half of the code and ran only the SQL_SELECT from the one database - and it worked as expected. So ...

Thanks a lot!

Best regards,

DataNibbler

P.S.: Do I have to add anything else to that keyword or can I use just that one command?

marcus_sommer

Hi DataNibbler,

just this command is enough.

disconnect

Dieser Befehl beendet eine bestehende OLE DB-, ODBC- oder benutzerdefinierte Verbindung. Der Befehl ist optional. denn die Verbindung wird ohnehin beendet, wenn ein neuer connect-Befehl im Skript erscheint oder wenn die Ausführung des Skripts beendet ist. Die Syntax lautet:

disconnect

Beispiel:

     disconnect;

- Marcus

datanibbler
Champion
Champion
Author

Hi,

strangely, there still seemed to be a confusion, judging from the Plant_Key in the table, I cannot tell from anything else which database the table comes from, there is only this Plant_Key ...

Well, maybe it takes a little time. I will try, when I implement all this into one big app to run once a month, to put some blocks of code between the connections, hopefully that will help ..

marcus_sommer

Hi DataNibbler,

I usually use in such cases something like: 'abc' as Source and 'xyz' as Source within the loadings which could need some efforts if there are many loadings and transformings through concatenate or joins/mappings to put them everywhere through.

Another way could be to implement some additional qualify-loadings between your normal loads to be able to see the intermediate steps. Quite useful is also the use of the EasyQlik QViewer - viewer for QVD files especially with this sub-routine: Inspecting QVD files at script runtime with QViewer.

- Marcus