Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

MVP & Luminary
MVP & Luminary

Re: Store QVD loop failing in multiple ODBC connections

Hi,

Try like this, it is working, no need of macro you can directly use For loop

Table1:

LOAD

*

INLINE [

A,B

1,2

];

Table2:

LOAD

*

INLINE [

A,B,C

1,2, 3

];

FOR i =0 to NoOfTables()-1

  LET vTabName =TableName(0);

  STORE $(vTabName) into $(vTabName).qvd (qvd);

  DROP Table $(vTabName);

NEXT i

Regards,

Jagan.

MVP & Luminary
MVP & Luminary

Re: Store QVD loop failing in multiple ODBC connections

Hi,

Please find attached file for solution.

Regards,

Jagan.

johnhhtp2
Contributor II

Re: Store QVD loop failing in multiple ODBC connections

Here none of these tables getting exported to QVD.

When I put comment on CALL, everything is normal where I can see both tables getting exported  from multiple databases.

John

johnhhtp2
Contributor II

Re: Store QVD loop failing in multiple ODBC connections

Thanks Jagan for the reply, I have no problem when I have single database connection, the problem  is occuring when connecting to multiple databse connections in single qvw file.

As Peter & Marcus said the database connection is getting lost from the 1st database, when moving to the 2nd ODBC connection.

what i want is  qvd's(of 1st ODBC connection ) should get  created before moving to second ODBC connection, this would solve the problem,

John

Highlighted
cesaraccardi
Valued Contributor

Re: Store QVD loop failing in multiple ODBC connections

Hi John,

What if instead of using a SUB routine you move the above lines to the the last tab of the script:

FOR i =0 to NoOfTables()-1

LET vTabName =TableName(0);

STORE $(vTabName) into $(vTabName).qvd (qvd);

DROP Table $(vTabName);

NEXT i

Does it work?

Cesar

MVP & Luminary
MVP & Luminary

Re: Store QVD loop failing in multiple ODBC connections

I think you should try what Peter suggested to see if the sql will be executed and the two tables exists. Maybe you need a 32-bit connection or if the data-structure from both tables are the same they will be automatically concatenated ... Further, do you use any ERRORMODE within this script?

Another possibility is of course to use a loop which contained the sql + storing + dropping. Especially if you have larger loads or you want use statements like exists() you might need to drop tables as early as possible.

- Marcus

Partner
Partner

Re: Store QVD loop failing in multiple ODBC connections

Hi,

You have to call the SUB() after each database connection. Because what you are doing is connecting to different database and loading, so call the subroutine after each connection and loading

johnhhtp2
Contributor II

Re: Store QVD loop failing in multiple ODBC connections

Thanks Jagan,Cesar, Marcus & peter  its working as per your suggestions,

I kept the for loop without sub routine  in the last tab and its working.

Here I didn't even wrote any disconnect statement for each ODBC connection, still worked fine with no issues.

Thanks once again.

John