Run SQL Server parametrized stored procedure

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

vpilia
Posts: 1
Joined: Mon Nov 13, 2017 8:59 am

Run SQL Server parametrized stored procedure

Postby vpilia » Mon Nov 13, 2017 9:19 am

Hello,

I need to execute a parametrized stored procedure on MS SQL Server, that does not pull data.
It is a write-to-log in fact.
(stored procedure works fine when launched from SQL Management Studio)

Tried to open a dummy workfile but won't work

Code: Select all

wfopen(wf=xxx,page=d,type=odbc,timeout=120) Description=DEV_STG;DRIVER=ODBC Driver 13 for SQL Server;SERVER=servername;Trusted_Connection=Yes;APP=EViews;DATABASE=STG;  "{call [STG].[Eviews].[log_Eviews_staging] ('"{%param1}"', '"{%param2}"')}" @keep *
wfclose xxx


Error message:
ODBC Error unable to connect to driver: in "WFOPEN
(WF=XXX,PAGE=D,TYPE=ODBC,TIMEOUT=120)
DESCRIPTION=DEV_STG;DRIVER=ODBC DRIVER 13 FOR SQL
SERVER;SERVER=CHTSGVA-DB83,1435;TRUSTED_CONNECTI
ON=YES;APP=EVIEWS;DATABASE=STG; "{CALL
[STG].[EVIEWS].[LOG_EVIEWS_STAGING] ('"CHL"',
'"CHILE"')}" @KEEP *".


Bizarrely, the same driver works few lines before on the wfsave command

Any ideas?

EViews Steve
EViews Developer
Posts: 788
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Run SQL Server parametrized stored procedure

Postby EViews Steve » Tue Nov 14, 2017 8:29 am

Try using quotes around your connection string, like this:

Code: Select all

wfopen(wf=xxx,page=d,type=odbc,timeout=120) "Description=DEV_STG;DRIVER=ODBC Driver 13 for SQL Server;SERVER=servername;Trusted_Connection=Yes;APP=EViews;DATABASE=STG;"  "{call [STG].[Eviews].[log_Eviews_staging] ('"{%param1}"', '"{%param2}"')}" @keep *

But honestly, calling a stored procedure this way via WFOPEN is probably not the best way to do it as WFOPEN will try and expect something to be returned by the call. Why don't you create a separate program that calls your stored procedure (such as via VBS script or a simple .NET console program), then call the program from EViews using SHELL or SPAWN?


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 28 guests