Variables as parameters in SQL procedure call

For questions regarding programming in the EViews programming language.

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

lgazire
Posts: 16
Joined: Mon Feb 11, 2019 8:56 am

Variables as parameters in SQL procedure call

Postby lgazire » Thu Feb 21, 2019 10:26 am

I want to execute the following case?

Code: Select all

   %s = @str(!productId)
   pageload(page={%produto}, type=odbc)  "Description=DEsc;DRIVER=ODBC Driver 13 for SQL Server;SERVER=localhost;Trusted_Connection=Yes;APP=EViews;DATABASE=Db;" "{call USP_SEL_GetMovingAveragePriceQuote ("+%s+"))}"


But i got the error:

Code: Select all

 ODBC Error 42000: Syntax error, permission violation, or
 other nonspecific error in "PAGELOAD(PAGE=RICE,
 TYPE=ODBC)  "DESCRIPTION=DESC;DRIVER=ODBC
 DRIVER 13 FOR SQL SERVER;SERVER=LOCALHOST;TRUSTED
_CONNECTION=YES;APP=EVIEWS;DATABASE=DB;" "{CALL USP_SEL_GETMOVINGAVERAGEPRICEQUOTE ("+"1"+"))}"".



If i pass directly it doesn´t show any errors, what am i doing wrong?

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

Re: Variables as parameters in SQL procedure call

Postby EViews Gareth » Thu Feb 21, 2019 10:37 am

Looks like you have two close parens at the end, but only one open paren.

Also, it might be safer to build up that second string as a variable and use that:

Code: Select all

%s = "{call USP_SEL_GetMovingAveragePriceQuote ("+@str(!productID)+")}"
pageload(page={%produto}, type=odbc)  "Description=DEsc;DRIVER=ODBC Driver 13 for SQL Server;SERVER=localhost;Trusted_Connection=Yes;APP=EViews;DATABASE=Db;" %s
Follow us on Twitter @IHSEViews

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

Re: Variables as parameters in SQL procedure call

Postby EViews Gareth » Thu Feb 21, 2019 10:45 am

Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 30 guests