Using variables in Stored Procedures

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

linkan
Posts: 14
Joined: Mon Aug 24, 2015 7:23 am

Using variables in Stored Procedures

Postby linkan » Mon Aug 24, 2015 7:29 am

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).

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12543
Joined: Tue Sep 16, 2008 5:38 pm

Re: Using variables in Stored Procedures

Postby EViews Gareth » Mon Aug 24, 2015 7:34 am

Could you provide more information on what you're trying to do (and where EViews is involved)?
Follow us on Twitter @IHSEViews

linkan
Posts: 14
Joined: Mon Aug 24, 2015 7:23 am

Re: Using variables in Stored Procedures

Postby linkan » Mon Aug 24, 2015 11:43 pm

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12543
Joined: Tue Sep 16, 2008 5:38 pm

Re: Using variables in Stored Procedures

Postby EViews Gareth » Tue Aug 25, 2015 7:34 am

Code: Select all

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

linkan
Posts: 14
Joined: Mon Aug 24, 2015 7:23 am

Re: Using variables in Stored Procedures

Postby linkan » Wed Aug 26, 2015 5:44 am

Thank you very much.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 6 guests