Page 1 of 1

Vensim ODBC scenario selection via run name

Posted: Mon Jun 29, 2020 3:39 am
by pav80
Hi,

Saw on https://www.vensim.com/documentation/va ... enario.htm that one can refer to the name of the current Vensim simulation run by using the character (!).

Therefore if one has the below ODBC query, can one actually send the scenario name in the form of the character (!) to the select statement?

More specifically wondering if this part of the SQL code "AND

Code: Select all

 IN ('STEPS')" can be changed to use ! and automatically get the name of the scenario from the run name.

Tried it but doesn't seem to work, so wanted to see if others had experience with this?

:DATA
	:VARNAME=[Code FLOW]
		:SUB=[Code PRODUCT]
		:SUB=[Code REGION]
		:TIME=[YEAR]
		:VALUE=[VALUE] 
		:SELECT DW
		WHERE [Code FLOW] IN ('BASEDECLINE')\
		AND [Code UNIT] IN ('DECIMAL')\
		AND [Code PRODUCT] IN ('GAS')\
		AND [Code CATEGORY] IN ('ENERGY')\
		AND [Code PUBLICATION] IN ('2020ED')\
		AND [Code SCENARIO] IN ('BASE')

Thanks, Pawel

Re: Vensim ODBC scenario selection via run name

Posted: Mon Jun 29, 2020 11:50 am
by Administrator
Can you upload the database/model/VDI files that you are using?

Re: Vensim ODBC scenario selection via run name

Posted: Mon Jun 29, 2020 2:12 pm
by tomfid
My suspicion is that you can use ! in a simple statement, as in the help example, but not in a complex select statement. If you use :FIELD statements instead of your WHERE / AND select, it should work.