Page 1 of 1

Using variables in Stored Procedures

Posted: Mon Aug 24, 2015 7:29 am
by linkan
I work at a governmental agency that conducts a survey once per month, and the results are stored in an SQL database. I have now started to use ODBC connection to that database, but I can not pass the info from variables to the stored procedure.

Example:
call BearbetningHamtaUtskick (@sPeriod='201502', @sSektor='G')

I want to be able to set the sPeriod from user input (to get the information from the database about the current months answers).

Re: Using variables in Stored Procedures

Posted: Mon Aug 24, 2015 7:34 am
by EViews Gareth
Could you provide more information on what you're trying to do (and where EViews is involved)?

Re: Using variables in Stored Procedures

Posted: Mon Aug 24, 2015 11:43 pm
by linkan
I am trying to use ODBC to get data to Eviews from an SQL database, so I can continue to work on it in Eviews. The full code is enclosed below, with uid and pwd for the ODBC source changed.

Code: Select all

Mode Quiet Close @All %per = "1502" %perSQL = "20" + @Left(%per,4) %per2 = "20" + @Left(%per,2) + "m" + @Right(%per,2) WfCreate(page=m) TestODBC m {%per2} {%per2} %dbcred = "dsn=Dbutv;uid=eviews;pwd=eviews" PageLoad(type=odbc,page=Utskick) {%dbcred} "{call BearbetningHamtaUtskick (@sPeriod='201502', @sSektor='G')}"
I would like to be able to use %perSQL instead of the hard coded 201502 within the call part of the PageLoad at the bottom.

Re: Using variables in Stored Procedures

Posted: Tue Aug 25, 2015 7:34 am
by EViews Gareth

Code: Select all

%date = "201502" %callcode = "{ call BearbetningHamtaUtskick (@sPeriod='"+%date+"',@sSektor='G')}" PageLoad(type=odbc,page=Utskick) {%dbcred} %callcode

Re: Using variables in Stored Procedures

Posted: Wed Aug 26, 2015 5:44 am
by linkan
Thank you very much.