Page 1 of 1

Variables as parameters in SQL procedure call

Posted: Thu Feb 21, 2019 10:26 am
by lgazire
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?

Re: Variables as parameters in SQL procedure call

Posted: Thu Feb 21, 2019 10:37 am
by EViews Gareth
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

Re: Variables as parameters in SQL procedure call

Posted: Thu Feb 21, 2019 10:45 am
by EViews Gareth