cancel
Showing results for 
Search instead for 
Did you mean: 

Parameters in query generator

dilipkumbhar
Participant
0 Kudos

I have developed a query which accepts parameter while executing. I have used this syntax,

SeriesName ='[%1]' 

In the above query , all the names of series are loaded. I want to load the series name as per my requirement. I don't want entire list. Is there any way to load customized list of parameters ?

Accepted Solutions (0)

Answers (2)

Answers (2)

dilipkumbhar
Participant
0 Kudos

I tried this code ,

/* select * from NNM1 x */
DECLARE @SeriesName AS NVARCHAR(100)
/* WHERE x.SeriesName like 'RND%'*/
SET @SeriesName = /* x.SeriesName */ '[%0]'

select @SeriesName FOR BROWSE

How do I specify where condition ? I am getting list of all series. I want series whose name starts with RND'

Johan_H
Active Contributor

Hi,

You can't do it this way. Theoretically you would do this:

/* select * from NNM1 x where x.SeriesName like'RND%' */
DECLARE @SeriesName AS NVARCHAR(100)
SET @SeriesName = /* x.SeriesName */ '[%0]'

However, B1 simply ignores the WHERE clause. The method I suggested is currently the only possibly viable one.

Regards,

Johan

Johan_H
Active Contributor
0 Kudos

Hi,

Currently this might be possible with a somewhat complicated workaround, that I have not tested:

  1. Create a User Defined Table with a User Defined Field of the same type and length as the SeriesName field
  2. Create a job in MS SQL Server Management Studio (or similar in HANA, if there is such a thing), that selects the SeriesNames per your requirement, and inserts the result into the UDF. Schedule this job to run as often as needed.
  3. Try your query like this:
/* select * from [@YOUR_UDT] x */
DECLARE @SeriesName AS NVARCHAR(100)
SET @SeriesName = /* x.U_SeriesName */ '[%0]'

SELECT *
FROM SomeTable
WHERE SeriesName = @SeriesName

Regards,

Johan