<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Determine database type in script in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Determine-database-type-in-script/m-p/1151994#M20680</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your answer. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I didn't know you could specify the dialect used by Qlik. I'll consider using this if I need to do a specific query in the future.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Olivier.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Aug 2016 06:39:53 GMT</pubDate>
    <dc:creator />
    <dc:date>2016-08-10T06:39:53Z</dc:date>
    <item>
      <title>Determine database type in script</title>
      <link>https://community.qlik.com/t5/App-Development/Determine-database-type-in-script/m-p/1151990#M20676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are currently developping an application &lt;SPAN style="font-size: 13.3333px;"&gt;for our customers&lt;/SPAN&gt; in QlikSense . We would like this app to work on different DB Engines (mainly SQL Server and Oracle).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that we have in the script a statement that uses tables specific to the engine (oracle or SQLServer); For instance 'select blabla from sys.tables'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to determine the DB behind an OLE DB connection? That way I may be able to use one query or another according to the DB Type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I searched quite a lot but didn't find anything that would work...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you guys could help, it would be great !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot,&lt;/P&gt;&lt;P&gt;Olivier.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Aug 2016 19:28:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Determine-database-type-in-script/m-p/1151990#M20676</guid>
      <dc:creator />
      <dc:date>2016-08-08T19:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Determine database type in script</title>
      <link>https://community.qlik.com/t5/App-Development/Determine-database-type-in-script/m-p/1151991#M20677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For Oracle this SQL will return one row giving the Oracle version&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SELECT * FROM v$version&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;WHERE banner LIKE 'Oracle%';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;For SQL Server it would fail, but I expect there would be a SQL server equivalent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From the results returned you should be able to suss whether Oracle or SQL Server and with some IF logic and then execute your desired SQL.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2016 10:04:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Determine-database-type-in-script/m-p/1151991#M20677</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-09T10:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: Determine database type in script</title>
      <link>https://community.qlik.com/t5/App-Development/Determine-database-type-in-script/m-p/1151992#M20678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If they are different Libs you could state the connection in a variable and use that to determine which statement to use when loading data throughout the app:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let vConnection = 'sql';&lt;/P&gt;&lt;P&gt;LIB CONNECT TO $(vConnection);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if vConnection = 'sql' then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; use sql statements&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; use Oracle statements&lt;/P&gt;&lt;P&gt;endif&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another solution is to test which engine you are connected to by setting errormode = 0 to prevent the script from stopping if your test fails by doing something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set ErrorMode=0;&lt;/P&gt;&lt;P&gt;let &lt;SPAN style="font-size: 13.3333px;"&gt;ScriptErrorCount = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First 1 Load * From your SQL database with SQL statement;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;if $(ScriptErrorCount) = 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let vConnection = 'SQL';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;endif&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Then do the same test for Oracle but with Oracle specific statement and use vConnection variable to determine which LOAD statement to use. Remember to set &lt;SPAN style="font-size: 13.3333px;"&gt;ErrorMode back to 1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would prefer option 1, it's never pretty to crash your script on purpose...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2016 11:40:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Determine-database-type-in-script/m-p/1151992#M20678</guid>
      <dc:creator>kjhertz</dc:creator>
      <dc:date>2016-08-09T11:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Determine database type in script</title>
      <link>https://community.qlik.com/t5/App-Development/Determine-database-type-in-script/m-p/1151993#M20679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I actually found a 'clean' way to achieve what I wanted to do. I use the 'SQLTABLES' fonction to get the table list, this way it's compatible with any engine :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;allTables:&lt;/P&gt;&lt;P&gt;load &lt;/P&gt;&lt;P&gt;&amp;nbsp; TABLE_NAME, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TABLE_TYPE, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SubField(TABLE_NAME, '_CC_' ,1) AS Master_Table;&lt;/P&gt;&lt;P&gt;SQLTABLES;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* &lt;/P&gt;&lt;P&gt;&amp;nbsp; Restriction de la liste aux tables contenant '_CC_' et calcul du nom de la table de donnée liée&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*/&lt;/P&gt;&lt;P&gt;charTablesList:&lt;/P&gt;&lt;P&gt;load &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TABLE_NAME,&lt;/P&gt;&lt;P&gt;&amp;nbsp; SubField(TABLE_NAME, '_CC_' ,1) AS Master_Table, /* Recuperation de la partie avant le '_CC_' */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TABLE_TYPE&lt;/P&gt;&lt;P&gt;Resident allTables&lt;/P&gt;&lt;P&gt;where TABLE_TYPE = 'TABLE'&lt;/P&gt;&lt;P&gt;and TABLE_NAME LIKE '*_CC_*'; ! !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2016 12:01:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Determine-database-type-in-script/m-p/1151993#M20679</guid>
      <dc:creator />
      <dc:date>2016-08-09T12:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: Determine database type in script</title>
      <link>https://community.qlik.com/t5/App-Development/Determine-database-type-in-script/m-p/1151994#M20680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your answer. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I didn't know you could specify the dialect used by Qlik. I'll consider using this if I need to do a specific query in the future.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Olivier.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 06:39:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Determine-database-type-in-script/m-p/1151994#M20680</guid>
      <dc:creator />
      <dc:date>2016-08-10T06:39:53Z</dc:date>
    </item>
  </channel>
</rss>

